Git development
 help / color / mirror / Atom feed
From: Pavel Pisa <pisa@cmp.felk.cvut.cz>
To: Petr Baudis <pasky@ucw.cz>, git@vger.kernel.org
Subject: GIT and COGITO individual scripts hidding from PATH
Date: Fri, 27 May 2005 18:24:04 +0200	[thread overview]
Message-ID: <200505271824.05105.pisa@cmp.felk.cvut.cz> (raw)
In-Reply-To: <20050524111333.GA11223@pasky.ji.cz>

Hello All,

I prefer to have as small number of executables in /usr/bin
and /user/local/bin as possible. I have tried to push original
Peter's git script to this direction for my strange personal taste.
COGITO has taken different direction than. I have hidden cogito and git
under wrapper to make me happy again. I thing that it is against good
opensource habits to keep changes secret even if I do not expect
interrest in this version. But may it be, that it can make
happy somebody with same taste as I have.

The "cgt" is wrapper for all cogito programs. If cogito is
build and installed to any prefix directory (/opt/git-cogito in my case)
and script is copied to bin subdirectory (/opt/git-cogito/bin),
then only single symbolic link from some searchable directory on PATH
is enough to call all cogito commands
  cgt pull
  cgt update
so usage is more convenient for my fingers learned to type cvs up, etc.
I think, that addition of intelligent bash completion could be done easier
if number of the first level commands to cover is smaller.

Best wishes

        Pavel Pisa

"cgt" script
--------------------------------------------------------------------------------
#!/usr/bin/env bash
#
# The GIT scripted toolkit.
# Copyright (c) Petr Baudis, 2005
#
# Script to automatically wrap individual GIT commands under one script
# for those, who prefer only one or two links in /usr/local/bin
# This script added by Pavel Pisa <pisa@cmp.felk.cvut.cz>
#
# This command mostly only multiplexes to the individual scripts based
# on the first argument.

error () {
	echo cgt: $@ >&2
}
die () {
	error $@
	exit 1
}

if [ -z "$GIT_TOOLS_DIR" ] ; then
	GIT_MUXBINARY_DIR="$(dirname "$0")"
	if [ -h "$0" ]; then
		#GIT_TOOLS_DIR="$(ls -l "$0" | sed 's/^.*-> *\(.*\) *$/\1/')"
		GIT_TOOLS_DIR="$(readlink -f -n $0)"
	        GIT_TOOLS_DIR="$(dirname "$GIT_TOOLS_DIR")"
		GIT_TOOLS_DIR="$(cd "$GIT_MUXBINARY_DIR" ; cd "$GIT_TOOLS_DIR" ; pwd )"
	else
		GIT_TOOLS_DIR="$(cd "$GIT_MUXBINARY_DIR" ; pwd )"
	fi

	if [ -z "$(echo :$PATH: | sed -n -e 's#:'"$GIT_TOOLS_DIR"':#yes#p' )" ] ; 
then
		export PATH="$GIT_TOOLS_DIR:$PATH"
	fi

	export GIT_TOOLS_DIR
fi

#echo =$GIT_TOOLS_DIR
#echo PATH=$PATH
#echo CWD=$(pwd)
#exit 

help () {
	echo "cgt recognizes next commands:" >&2 
	(cd $GIT_TOOLS_DIR ; ls cg-* ) | sed -n -e 's/\<cg-\([^ ]*\)\>/\1/pg' >&2 
}


cmd=$1; shift

if [ ! "$cmd" ]; then
	error "missing command"
	help
	exit 1
fi

cgt_cmd_exe="${GIT_TOOLS_DIR}/cg-$cmd"

if [ ! -e "$cgt_cmd_exe" ]; then
	error "unrecognized command ${cmd}"
	help
	exit 1
fi

"$cgt_cmd_exe" "$@"
--------------------------------------------------------------------------------

"git" script
--------------------------------------------------------------------------------
#!/usr/bin/env bash
#
# The GIT scripted toolkit.
# Copyright (c) Petr Baudis, 2005
#
# Script to automatically wrap individual GIT commands under one script
# for those, who prefer only one or two links in /usr/local/bin
# This script added by Pavel Pisa <pisa@cmp.felk.cvut.cz>
#
# This command mostly only multiplexes to the individual scripts based
# on the first argument.

error () {
	echo git: $@ >&2
}
die () {
	error $@
	exit 1
}

if [ -z "$GIT_TOOLS_DIR" ] ; then
	GIT_MUXBINARY_DIR="$(dirname "$0")"
	if [ -h "$0" ]; then
		#GIT_TOOLS_DIR="$(ls -l "$0" | sed 's/^.*-> *\(.*\) *$/\1/')"
		GIT_TOOLS_DIR="$(readlink -f -n $0)"
	        GIT_TOOLS_DIR="$(dirname "$GIT_TOOLS_DIR")"
		GIT_TOOLS_DIR="$(cd "$GIT_MUXBINARY_DIR" ; cd "$GIT_TOOLS_DIR" ; pwd )"
	else
		GIT_TOOLS_DIR="$(cd "$GIT_MUXBINARY_DIR" ; pwd )"
	fi

	if [ -z "$(echo :$PATH: | sed -n -e 's#:'"$GIT_TOOLS_DIR"':#yes#p' )" ] ; 
then
		export PATH="$GIT_TOOLS_DIR:$PATH"
	fi

	export GIT_TOOLS_DIR
fi

#echo =$GIT_TOOLS_DIR
#echo PATH=$PATH
#echo CWD=$(pwd)
#exit 

help () {
	echo "git recognizes next commands:" >&2 
	(cd $GIT_TOOLS_DIR ; ls git-* ) | sed -n -e 's/\<git-\([^ ]*\)\>/\1/pg' >&2 
}


cmd=$1; shift

if [ ! "$cmd" ]; then
	error "missing command"
	help
	exit 1
fi

git_cmd_exe="${GIT_TOOLS_DIR}/git-$cmd"

if [ ! -e "$git_cmd_exe" ]; then
	error "unrecognized command ${cmd}"
	help
	exit 1
fi

"$git_cmd_exe" "$@"
--------------------------------------------------------------------------------


  parent reply	other threads:[~2005-05-27 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200504132249.16848.pisa@cmp.felk.cvut.cz>
2005-04-13 22:55 ` Slight enhancement of GIT wrapper Petr Baudis
2005-04-13 23:07   ` Johannes Schindelin
2005-04-13 23:10   ` Johannes Schindelin
     [not found] ` <200505241235.02597.pisa@cmp.felk.cvut.cz>
     [not found]   ` <20050524111333.GA11223@pasky.ji.cz>
2005-05-27 16:24     ` Pavel Pisa [this message]
2005-05-27 16:29       ` GIT and COGITO individual scripts hidding from PATH Pavel Pisa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200505271824.05105.pisa@cmp.felk.cvut.cz \
    --to=pisa@cmp.felk.cvut.cz \
    --cc=git@vger.kernel.org \
    --cc=pasky@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox