Add --show option to build-dir command
The new option shows the current build directory, if present.
This commit is contained in:
parent
c61c86e979
commit
a96aa50fbe
@ -1,6 +1,7 @@
|
|||||||
#compdef build-dir
|
#compdef build-dir
|
||||||
|
|
||||||
_arguments \
|
_arguments \
|
||||||
'(-h --help)'{-h,--help}'[]' \
|
'(-h --help)'{-h,--help}'[show this help message and exit]' \
|
||||||
|
'(-s --show)'{-s,--show}'[show the current build directory]' \
|
||||||
'--build[invoke a build after selection]' \
|
'--build[invoke a build after selection]' \
|
||||||
'1:directory:_files'
|
'1:directory:_files'
|
||||||
|
@ -32,8 +32,8 @@ fi
|
|||||||
# Interactively choose a `~build` directory for `build` to build.
|
# Interactively choose a `~build` directory for `build` to build.
|
||||||
build-dir() {
|
build-dir() {
|
||||||
local usage='usage: build-dir [-h] [--build] [<directory>]'
|
local usage='usage: build-dir [-h] [--build] [<directory>]'
|
||||||
local -a help do_build
|
local -a help show do_build
|
||||||
zparseopts -D h=help -help=help -build=do_build
|
zparseopts -D h=help -help=help s=show -show=show -build=do_build
|
||||||
if [[ -n $help ]]; then
|
if [[ -n $help ]]; then
|
||||||
cat << EOF
|
cat << EOF
|
||||||
$usage
|
$usage
|
||||||
@ -45,12 +45,22 @@ positional arguments:
|
|||||||
|
|
||||||
optional arguments:
|
optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
|
-s, --show show the current build directory
|
||||||
--build invoke a build after selection
|
--build invoke a build after selection
|
||||||
EOF
|
EOF
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
error() { echo "\e[31merror:\e[0m $1" }
|
error() { echo "\e[31merror:\e[0m $1" }
|
||||||
warning() { echo "\e[33mwarning:\e[0m $1" }
|
warning() { echo "\e[33mwarning:\e[0m $1" }
|
||||||
|
if [[ -n $show ]]; then
|
||||||
|
if [[ ! -n $build_dir ]]; then
|
||||||
|
error "build directory not set"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo "$build_dir"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
local local_build_dir
|
local local_build_dir
|
||||||
if [[ ${#*} -gt 1 ]]; then
|
if [[ ${#*} -gt 1 ]]; then
|
||||||
echo $usage
|
echo $usage
|
||||||
|
Loading…
x
Reference in New Issue
Block a user