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
|
||||
|
||||
_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]' \
|
||||
'1:directory:_files'
|
||||
|
@ -32,8 +32,8 @@ fi
|
||||
# Interactively choose a `~build` directory for `build` to build.
|
||||
build-dir() {
|
||||
local usage='usage: build-dir [-h] [--build] [<directory>]'
|
||||
local -a help do_build
|
||||
zparseopts -D h=help -help=help -build=do_build
|
||||
local -a help show do_build
|
||||
zparseopts -D h=help -help=help s=show -show=show -build=do_build
|
||||
if [[ -n $help ]]; then
|
||||
cat << EOF
|
||||
$usage
|
||||
@ -45,12 +45,22 @@ positional arguments:
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-s, --show show the current build directory
|
||||
--build invoke a build after selection
|
||||
EOF
|
||||
return
|
||||
fi
|
||||
error() { echo "\e[31merror:\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
|
||||
if [[ ${#*} -gt 1 ]]; then
|
||||
echo $usage
|
||||
|
Loading…
x
Reference in New Issue
Block a user