Move `command_` (back) to `x_`, too verbose
This commit is contained in:
parent
e3f8a5cc01
commit
1070f958f7
|
@ -15,8 +15,10 @@ This `cmd` inside can then be renamed and finished.
|
||||||
|
|
||||||
* Name repos containing single bash commands with `cmd-`
|
* Name repos containing single bash commands with `cmd-`
|
||||||
* Name template repos beginning with `template-`
|
* Name template repos beginning with `template-`
|
||||||
* Start command functions with `command_` to be completed
|
* Start command functions with `x_` to be completed
|
||||||
* Start command functions with `command__` to not be completed
|
* Start command functions with `x__` to not be completed
|
||||||
|
|
||||||
|
Think of the `x` as in "executable" command.
|
||||||
|
|
||||||
If you want to keep a command but hide it from users just add another
|
If you want to keep a command but hide it from users just add another
|
||||||
underscore to the prefix which turns it into a hidden command, which
|
underscore to the prefix which turns it into a hidden command, which
|
||||||
|
@ -246,5 +248,5 @@ Displays a summary of usage.
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
*Autogenerated Tue Aug 31 09:54:00 AM EDT 2021*
|
*Autogenerated Tue Aug 31 09:39:48 PM EDT 2021*
|
||||||
|
|
||||||
|
|
38
cmd
38
cmd
|
@ -35,8 +35,10 @@ This `cmd` inside can then be renamed and finished.
|
||||||
|
|
||||||
* Name repos containing single bash commands with `cmd-`
|
* Name repos containing single bash commands with `cmd-`
|
||||||
* Name template repos beginning with `template-`
|
* Name template repos beginning with `template-`
|
||||||
* Start command functions with `command_` to be completed
|
* Start command functions with `x_` to be completed
|
||||||
* Start command functions with `command__` to not be completed
|
* Start command functions with `x__` to not be completed
|
||||||
|
|
||||||
|
Think of the `x` as in "executable" command.
|
||||||
|
|
||||||
If you want to keep a command but hide it from users just add another
|
If you want to keep a command but hide it from users just add another
|
||||||
underscore to the prefix which turns it into a hidden command, which
|
underscore to the prefix which turns it into a hidden command, which
|
||||||
|
@ -153,7 +155,7 @@ Please mention rwxrob.tv'
|
||||||
|
|
||||||
HELP[foo]='Foos things.'
|
HELP[foo]='Foos things.'
|
||||||
|
|
||||||
command_foo() {
|
x_foo() {
|
||||||
_filter "$@" && return $?
|
_filter "$@" && return $?
|
||||||
echo "would foo: $*"
|
echo "would foo: $*"
|
||||||
}
|
}
|
||||||
|
@ -166,18 +168,18 @@ HELP[bar]='
|
||||||
|
|
||||||
Bar the things.'
|
Bar the things.'
|
||||||
|
|
||||||
command_bar() {
|
x_foo() {
|
||||||
_buffer "$@" && return $?
|
_buffer "$@" && return $?
|
||||||
echo "would bar: $*"
|
echo "would bar: $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
HELP[some.config.setting]='Get and set `some.config.setting`.'
|
HELP[some.config.setting]='Get and set `some.config.setting`.'
|
||||||
|
|
||||||
command_some.config.setting() {
|
x_some.config.setting() {
|
||||||
command_config some.config.setting "$@"
|
x_config some.config.setting "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
command__hidden() {
|
x__hidden() {
|
||||||
_filter "$@" && return $?
|
_filter "$@" && return $?
|
||||||
echo "would run _hidden: $*"
|
echo "would run _hidden: $*"
|
||||||
}
|
}
|
||||||
|
@ -190,7 +192,7 @@ command__hidden() {
|
||||||
|
|
||||||
HELP[usage]='Displays a summary of usage.'
|
HELP[usage]='Displays a summary of usage.'
|
||||||
|
|
||||||
command_usage() {
|
x_usage() {
|
||||||
local -a cmds
|
local -a cmds
|
||||||
for c in "${COMMANDS[@]}"; do
|
for c in "${COMMANDS[@]}"; do
|
||||||
[[ ${c:0:1} =~ _ ]] && continue
|
[[ ${c:0:1} =~ _ ]] && continue
|
||||||
|
@ -219,7 +221,7 @@ to `$PAGER` (default: more).
|
||||||
Also see `readme` and `usage` commands.
|
Also see `readme` and `usage` commands.
|
||||||
'
|
'
|
||||||
|
|
||||||
command_help() {
|
x_help() {
|
||||||
local name="${1:-main}" title body
|
local name="${1:-main}" title body
|
||||||
title=$(_help_title "$name") || true
|
title=$(_help_title "$name") || true
|
||||||
if [[ -z "$title" ]]; then
|
if [[ -z "$title" ]]; then
|
||||||
|
@ -268,7 +270,7 @@ The `readme` command will output the embedded help documentation in raw
|
||||||
GitHub Flavored Markdown suitable for use as a `README.md` file on
|
GitHub Flavored Markdown suitable for use as a `README.md` file on
|
||||||
GitHub or similar hosting service.'
|
GitHub or similar hosting service.'
|
||||||
|
|
||||||
command_readme() {
|
x_readme() {
|
||||||
_trim "${HELP[main]}"
|
_trim "${HELP[main]}"
|
||||||
echo
|
echo
|
||||||
while IFS= read -r name; do
|
while IFS= read -r name; do
|
||||||
|
@ -280,8 +282,8 @@ command_readme() {
|
||||||
echo -e "----\n\n*Autogenerated $(date)*\n"
|
echo -e "----\n\n*Autogenerated $(date)*\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# command_json() { _jsonstr "$@"; }
|
# x_json() { _jsonstr "$@"; }
|
||||||
# command_urlencode() { _urlencode "$@"; }
|
# x_urlencode() { _urlencode "$@"; }
|
||||||
|
|
||||||
# -------------------------- config command --------------------------
|
# -------------------------- config command --------------------------
|
||||||
|
|
||||||
|
@ -352,7 +354,7 @@ Note that this is *not* the same as Java properties and other similar
|
||||||
format. It is designed for ultimate simplicity, efficiency, and
|
format. It is designed for ultimate simplicity, efficiency, and
|
||||||
portability.'
|
portability.'
|
||||||
|
|
||||||
command_config() {
|
x_config() {
|
||||||
case $1 in
|
case $1 in
|
||||||
dir*) shift; _config_dir "$@"; return $? ;;
|
dir*) shift; _config_dir "$@"; return $? ;;
|
||||||
path) shift; _config_path "$@"; return $? ;;
|
path) shift; _config_path "$@"; return $? ;;
|
||||||
|
@ -503,8 +505,8 @@ _buffer() {
|
||||||
# `complete -C foo foo` > `source <(foo bloated_completion)`
|
# `complete -C foo foo` > `source <(foo bloated_completion)`
|
||||||
|
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
[[ $line =~ ^declare\ -f\ command_ ]] || continue
|
[[ $line =~ ^declare\ -f\ x_ ]] || continue
|
||||||
COMMANDS+=( "${line##declare -f command_}" )
|
COMMANDS+=( "${line##declare -f x_}" )
|
||||||
done < <(declare -F)
|
done < <(declare -F)
|
||||||
mapfile -t COMMANDS < \
|
mapfile -t COMMANDS < \
|
||||||
<(LC_COLLATE=C sort < <(printf "%s\n" "${COMMANDS[@]}"))
|
<(LC_COLLATE=C sort < <(printf "%s\n" "${COMMANDS[@]}"))
|
||||||
|
@ -522,7 +524,7 @@ _initialize
|
||||||
|
|
||||||
for c in "${COMMANDS[@]}"; do
|
for c in "${COMMANDS[@]}"; do
|
||||||
if [[ $c == "$EXE" ]]; then
|
if [[ $c == "$EXE" ]]; then
|
||||||
"command_$EXE" "$@"
|
"x_$EXE" "$@"
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -531,10 +533,10 @@ if [[ -n "$1" ]]; then
|
||||||
declare cmd="$1"; shift
|
declare cmd="$1"; shift
|
||||||
for c in "${COMMANDS[@]}"; do
|
for c in "${COMMANDS[@]}"; do
|
||||||
if [[ $c == "$cmd" ]]; then
|
if [[ $c == "$cmd" ]]; then
|
||||||
"command_$cmd" "$@"
|
"x_$cmd" "$@"
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
command_usage "$@"
|
x_usage "$@"
|
||||||
|
|
Loading…
Reference in New Issue