streamline usage with git
This commit is contained in:
parent
ee7898c5ee
commit
03818ff10e
2 changed files with 49 additions and 27 deletions
16
README.org
16
README.org
|
|
@ -10,16 +10,18 @@ It was inspired by [[https://wiki.ros.org/wstool][wstool]], [[https://github.com
|
||||||
* Usage
|
* Usage
|
||||||
|
|
||||||
#+begin_example
|
#+begin_example
|
||||||
Usage: gis [OPTIONS] [PATHS] ...
|
Usage: gis [COMMANDS] [OPTIONS]
|
||||||
|
|
||||||
Show a status summary of all Git repositories in PATHS.
|
Show a status summary of all Git repositories which are found recursively in
|
||||||
The colon-seperated environment variable $GIS_PATH is used if no PATH is given.
|
current work directory. If the colon-separated environment variable $GIS_PATH
|
||||||
If the variable isn't set, the current work directory is used.
|
is set, the declared directories will be used instead.
|
||||||
|
|
||||||
|
COMMANDS
|
||||||
|
fetch Execute 'git fetch --prune --all' for all found repositories
|
||||||
|
pull Execute 'git pull' for all found repositories which are behind upstream
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-f, --fetch Execute 'git fetch --prune --all' for all repositories in PATHS
|
-p, --path PATH Use PATH for searching Git repositories
|
||||||
-p, --pull Execute 'git pull' for all repositories which are behind upstream
|
|
||||||
in PATHS
|
|
||||||
-h, --help Show this help message and exit
|
-h, --help Show this help message and exit
|
||||||
#+end_example
|
#+end_example
|
||||||
|
|
||||||
|
|
|
||||||
56
gis
56
gis
|
|
@ -11,19 +11,26 @@ text_yellow=$'\e[33m'
|
||||||
|
|
||||||
function print_usage {
|
function print_usage {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: gis [OPTIONS] [PATHS] ...
|
Usage: gis [COMMANDS] [OPTIONS]
|
||||||
|
|
||||||
Show a status summary of all Git repositories in PATHS.
|
Show a status summary of all Git repositories which are found recursively in
|
||||||
The colon-seperated environment variable \$GIS_PATH is used if no PATH is given.
|
current work directory. If the colon-separated environment variable \$GIS_PATH
|
||||||
If the variable isn't set, the current work directory is used.
|
is set, the declared directories will be used instead.
|
||||||
|
|
||||||
|
COMMANDS
|
||||||
|
fetch Execute 'git fetch --prune --all' for all found repositories
|
||||||
|
pull Execute 'git pull' for all found repositories which are behind upstream
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-f, --fetch Execute 'git fetch --prune --all' for all repositories in PATHS
|
-p, --path PATH Use PATH for searching Git repositories
|
||||||
-p, --pull Execute 'git pull' for all repositories which are behind upstream
|
|
||||||
in PATHS
|
|
||||||
-h, --help Show this help message and exit
|
-h, --help Show this help message and exit
|
||||||
EOF
|
EOF
|
||||||
exit "$1"
|
}
|
||||||
|
|
||||||
|
function error {
|
||||||
|
echo -e "${text_bold}${text_red}ERROR${text_reset} $1\n"
|
||||||
|
print_usage
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
|
|
@ -31,24 +38,37 @@ fetch=false
|
||||||
pull=false
|
pull=false
|
||||||
while (( "$#" )); do
|
while (( "$#" )); do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-f|--fetch)
|
-p|--path)
|
||||||
|
if [ -n "$2" ] && [ "${2:0:1}" != "-" ]; then
|
||||||
|
paths+=("$(realpath "$2")")
|
||||||
|
shift 2
|
||||||
|
else
|
||||||
|
error "Argument for ${text_bold}$1${text_reset} is missing"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
print_usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
error "Unsupported option ${text_bold}$1${text_bold}"
|
||||||
|
;;
|
||||||
|
fetch)
|
||||||
fetch=true
|
fetch=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-p|--pull)
|
f*)
|
||||||
|
error "Unsupported command ${text_bold}$1${text_reset}, did you mean ${text_bold}fetch${text_reset}?"
|
||||||
|
;;
|
||||||
|
pull)
|
||||||
pull=true
|
pull=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-h|--help)
|
p*)
|
||||||
print_usage 0
|
error "Unsupported command ${text_bold}$1${text_reset}, did you mean ${text_bold}pull${text_reset}?"
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
echo -e "${text_bold}${text_red}Unsupported flag${text_reset} $1\n"
|
|
||||||
print_usage 1
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
paths+=("$(realpath "$1")")
|
error "Unsupported command ${text_bold}$1${text_reset}"
|
||||||
shift
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue