Skip to content

Commit

Permalink
Use rbenv help infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
EdVanDance committed Mar 14, 2014
1 parent b8465b2 commit ad4f6cc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
6 changes: 1 addition & 5 deletions README.md
Expand Up @@ -11,12 +11,8 @@ $ git clone https://github.com/chriseppstein/rbenv-each.git

## Usage

You can get help for the `each` command by passing the `-h` option.

```
$ rbenv each -h
Usage: rbenv each [-v] ...
-v Verbose mode. Prints a header for each ruby.
$ rbenv help each
```

Verbose mode will print a header for each ruby so you can distinguish
Expand Down
47 changes: 26 additions & 21 deletions bin/rbenv-each
@@ -1,30 +1,35 @@
#!/usr/bin/env bash
#
# Summary: Execute a command for each Ruby version
#
# Usage: rbenv each [-v] <command> [arg1 arg2...]
#
# Executes a command for each Ruby version by setting RBENV_VERSION.
# Failures are collected and reported at the end.
#
# -v Verbose mode. Prints a header for each ruby.
#
set -e
[ -n "$RBENV_DEBUG" ] && set -x

verbose=""

usage() {
echo "Usage: rbenv each [-v] <command>"
echo " -v Verbose mode. Prints a header for each ruby."
}

while getopts ':vh' option; do
case "$option" in
'v') verbose=1 ;;
'h') usage; exit 0 ;;
'?')
usage >&2
exit 1
;;
esac
done
shift $(($OPTIND-1))
# Provide rbenv completions
if [ "$1" = "--complete" ]; then
echo -v
exit
fi

if [ -z "$1" ]; then
usage >&2
exit 1
if [ "$1" = "-v" ]; then
verbose=1
shift
fi

case "$1" in
"" | -* )
rbenv-help --usage each >&2
exit 1
;;
esac

GRAY=""
RED=""
YELLOW=""
Expand Down

0 comments on commit ad4f6cc

Please sign in to comment.