Move from `x_` to `x.` with explanation
This commit is contained in:
parent
159b2e78d7
commit
eedc4a7021
14
README.md
14
README.md
|
@ -15,10 +15,20 @@ This `cmd` inside can then be renamed and finished.
|
|||
|
||||
* 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 be completed
|
||||
* Name `CONFIG` accessors with `x.` and full path
|
||||
* Use dot (`.`) pathing in `CONFIG` key names
|
||||
|
||||
Think of `x` as in "executable" command.
|
||||
|
||||
> ⚠️
|
||||
> Note that all versions of Vim current have a bug that does not allow
|
||||
> dot (`.`) to be included in the function name even though it is
|
||||
> explicitly allowed by bash. So you may have to add `.` to your
|
||||
> `/usr/share/vim/vim82/syntax/sh.vim` file anywhere a function name
|
||||
> expression is defined. I have yet to isolate it out and override it in
|
||||
> my own `.vimrc`. It is a minimal edit.
|
||||
|
||||
## Builtins and Utilities
|
||||
|
||||
A number of builtin and frequently used utility functions have been
|
||||
|
@ -242,5 +252,5 @@ Displays a summary of usage.
|
|||
|
||||
----
|
||||
|
||||
*Autogenerated Tue Aug 31 10:00:12 PM EDT 2021*
|
||||
*Autogenerated Tue Aug 31 10:37:57 PM EDT 2021*
|
||||
|
||||
|
|
42
cmd
42
cmd
|
@ -35,10 +35,20 @@ This `cmd` inside can then be renamed and finished.
|
|||
|
||||
* 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 be completed
|
||||
* Name `CONFIG` accessors with `x.` and full path
|
||||
* Use dot (`.`) pathing in `CONFIG` key names
|
||||
|
||||
Think of `x` as in "executable" command.
|
||||
|
||||
> ⚠️
|
||||
> Note that all versions of Vim current have a bug that does not allow
|
||||
> dot (`.`) to be included in the function name even though it is
|
||||
> explicitly allowed by bash. So you may have to add `.` to your
|
||||
> `/usr/share/vim/vim82/syntax/sh.vim` file anywhere a function name
|
||||
> expression is defined. I have yet to isolate it out and override it in
|
||||
> my own `.vimrc`. It is a minimal edit.
|
||||
|
||||
## Builtins and Utilities
|
||||
|
||||
A number of builtin and frequently used utility functions have been
|
||||
|
@ -149,7 +159,7 @@ Please mention rwxrob.tv'
|
|||
|
||||
HELP[foo]='Foos things.'
|
||||
|
||||
x_foo () {
|
||||
x.foo () {
|
||||
_filter "$@" && return $?
|
||||
echo "would foo: $*"
|
||||
}
|
||||
|
@ -162,15 +172,15 @@ HELP[bar]='
|
|||
|
||||
Bar the things.'
|
||||
|
||||
x_bar() {
|
||||
x.bar() {
|
||||
_buffer "$@" && return $?
|
||||
echo "would bar: $*"
|
||||
}
|
||||
|
||||
HELP[some.config.setting]='Get and set `some.config.setting`.'
|
||||
|
||||
x_some.config.setting() {
|
||||
x_config some.config.setting "$@"
|
||||
x.some.config.setting() {
|
||||
x.config some.config.setting "$@"
|
||||
}
|
||||
|
||||
############################## BOILERPLATE ###########################
|
||||
|
@ -181,7 +191,7 @@ x_some.config.setting() {
|
|||
|
||||
HELP[usage]='Displays a summary of usage.'
|
||||
|
||||
x_usage() {
|
||||
x.usage() {
|
||||
local -a cmds
|
||||
for c in "${COMMANDS[@]}"; do
|
||||
[[ ${c:0:1} =~ _ ]] && continue
|
||||
|
@ -210,7 +220,7 @@ to `$PAGER` (default: more).
|
|||
Also see `readme` and `usage` commands.
|
||||
'
|
||||
|
||||
x_help() {
|
||||
x.help() {
|
||||
local name="${1:-main}" title body
|
||||
title=$(_help_title "$name") || true
|
||||
if [[ -z "$title" ]]; then
|
||||
|
@ -259,7 +269,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 or similar hosting service.'
|
||||
|
||||
x_readme() {
|
||||
x.readme() {
|
||||
_trim "${HELP[main]}"
|
||||
echo
|
||||
while IFS= read -r name; do
|
||||
|
@ -271,8 +281,8 @@ x_readme() {
|
|||
echo -e "----\n\n*Autogenerated $(date)*\n"
|
||||
}
|
||||
|
||||
# x_json() { _jsonstr "$@"; }
|
||||
# x_urlencode() { _urlencode "$@"; }
|
||||
# x.json() { _jsonstr "$@"; }
|
||||
# x.urlencode() { _urlencode "$@"; }
|
||||
|
||||
# -------------------------- config command --------------------------
|
||||
|
||||
|
@ -343,7 +353,7 @@ Note that this is *not* the same as Java properties and other similar
|
|||
format. It is designed for ultimate simplicity, efficiency, and
|
||||
portability.'
|
||||
|
||||
x_config() {
|
||||
x.config() {
|
||||
case $1 in
|
||||
dir*) shift; _config_dir "$@"; return $? ;;
|
||||
path) shift; _config_path "$@"; return $? ;;
|
||||
|
@ -494,8 +504,8 @@ _buffer() {
|
|||
# `complete -C foo foo` > `source <(foo bloated_completion)`
|
||||
|
||||
while IFS= read -r line; do
|
||||
[[ $line =~ ^declare\ -f\ x_ ]] || continue
|
||||
COMMANDS+=( "${line##declare -f x_}" )
|
||||
[[ $line =~ ^declare\ -f\ x\. ]] || continue
|
||||
COMMANDS+=( "${line##declare -f x.}" )
|
||||
done < <(declare -F)
|
||||
mapfile -t COMMANDS < \
|
||||
<(LC_COLLATE=C sort < <(printf "%s\n" "${COMMANDS[@]}"))
|
||||
|
@ -513,7 +523,7 @@ _initialize
|
|||
|
||||
for c in "${COMMANDS[@]}"; do
|
||||
if [[ $c == "$EXE" ]]; then
|
||||
"x_$EXE" "$@"
|
||||
"x.$EXE" "$@"
|
||||
exit $?
|
||||
fi
|
||||
done
|
||||
|
@ -522,10 +532,10 @@ if [[ -n "$1" ]]; then
|
|||
declare cmd="$1"; shift
|
||||
for c in "${COMMANDS[@]}"; do
|
||||
if [[ $c == "$cmd" ]]; then
|
||||
"x_$cmd" "$@"
|
||||
"x.$cmd" "$@"
|
||||
exit $?
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
x_usage "$@"
|
||||
x.usage "$@"
|
||||
|
|
Loading…
Reference in New Issue