Commit 4dceca4855362708a6199cf868463cdb66438e53
1 parent
0952e605da
Add support for boolean arguments to -bundle.
Currently, a keyword style argument given to -bundle command requires a value, like `--name=val`. With this, just a `--name` would imply `--name=true`
Showing 1 changed file with 10 additions and 3 deletions Side-by-side Diff
antigen.zsh
... | ... | @@ -37,9 +37,16 @@ antigen-bundle () { |
37 | 37 | |
38 | 38 | # Set spec values from keyword arguments, if any. The remaining arguments |
39 | 39 | # are all assumed to be keyword arguments. |
40 | - while [[ $1 == --*=* ]]; do | |
41 | - local arg_name="$(echo "$1" | cut -d= -f1 | sed 's/^--//')" | |
42 | - local arg_value="$(echo "$1" | cut -d= -f2)" | |
40 | + while [[ $1 == --* ]]; do | |
41 | + local arg="${1#--}" | |
42 | + | |
43 | + if [[ $arg != *=* ]]; then | |
44 | + arg="$arg=true" | |
45 | + fi | |
46 | + | |
47 | + local arg_name="${arg%\=*}" | |
48 | + local arg_value="${arg#*\=}" | |
49 | + | |
43 | 50 | eval "local $arg_name='$arg_value'" |
44 | 51 | shift |
45 | 52 | done |