From 6827a1ad55136372bdf0461903683556274ecb7d Mon Sep 17 00:00:00 2001 From: rwxrob Date: Tue, 10 Aug 2021 12:52:00 -0400 Subject: [PATCH] Move from `x_` to `command_`, closes #2 --- README.md | 14 +++++++------- cmd => command | 24 ++++++++++++------------ 2 files changed, 19 insertions(+), 19 deletions(-) rename cmd => command (91%) diff --git a/README.md b/README.md index 99eb226..36c1853 100644 --- a/README.md +++ b/README.md @@ -21,17 +21,17 @@ path to this repo to your `PATH`. That way you can keep up with updates. * Name repos containing single bash commands with `cmd-` * Name template repos beginning with `template-` -* Start command functions with `x_` to be completed -* Start command functions with `x__` to not be completed +* Start command functions with `command_` to be completed +* Start command functions with `command__` to not be completed ## Usage ``` -cmd -cmd usage -cmd help [] -cmd foo [] -cmd bar [] +command +command usage +command help [] +command foo [] +command bar [] ``` ## Commands diff --git a/cmd b/command similarity index 91% rename from cmd rename to command index 5afa5d5..3ac459a 100755 --- a/cmd +++ b/command @@ -32,26 +32,26 @@ completion, but still want them to be avaiable, just hidden. help[foo]='The `foo` command foos.' -x_foo() { +command_foo() { _filter "$@" && return $? echo "would foo: $*" } help[bar]='The `bar` command bars.' -x_bar() { +command_bar() { _buffer "$@" && return $? echo "would bar: $*" } -x__hidden() { +command__hidden() { _filter "$@" && return $? echo "would run _hidden: $*" } help[usage]='The `usage` command displays a summary of usage.' -x_usage() { +command_usage() { local -a cmds for c in "${COMMANDS[@]}"; do [[ ${c:0:1} =~ _ ]] && continue @@ -70,13 +70,13 @@ is written in CommonMark (Markdown) and will displayed as Web page if `pandoc` and `$HELP_BROWSER` are detected, otherwise, just the Markdown is sent to `$PAGER` (default: more).' -x_help() { +command_help() { local name="$1" if [[ -z "$name" ]];then for c in "${COMMANDS[@]}";do - x_help "$c" buildonly + command_help "$c" buildonly done - x_help main + command_help main return 0 fi local title="$EXE $name" @@ -113,8 +113,8 @@ _buffer() { } while IFS= read -r line; do - [[ $line =~ ^declare\ -f\ x_ ]] || continue - COMMANDS+=( "${line##declare -f x_}" ) + [[ $line =~ ^declare\ -f\ command_ ]] || continue + COMMANDS+=( "${line##declare -f command_}" ) done < <(declare -F) if [[ -n $COMP_LINE ]]; then @@ -127,7 +127,7 @@ fi for c in "${COMMANDS[@]}"; do if [[ $c == "$EXE" ]]; then - "x_$EXE" "$@" + "command_$EXE" "$@" exit $? fi done @@ -136,10 +136,10 @@ if [[ -n "$1" ]]; then declare cmd="$1"; shift for c in "${COMMANDS[@]}"; do if [[ $c == "$cmd" ]]; then - "x_$cmd" "$@" + "command_$cmd" "$@" exit $? fi done fi -x_usage "$@" +command_usage "$@"