Commit 8bba7ab7075aa03bf2714d6ea349403c6b8c45d4
1 parent
973558eee2
Use the new argument parsing function in -bundle.
Showing 1 changed file with 4 additions and 31 deletions Side-by-side Diff
antigen.zsh
... | ... | @@ -19,37 +19,10 @@ antigen-bundle () { |
19 | 19 | local no_local_clone=false |
20 | 20 | local btype=plugin |
21 | 21 | |
22 | - # Set spec values based on the positional arguments. | |
23 | - local position_args | |
24 | - position_args=(url loc) | |
25 | - local i=1 | |
26 | - while ! [[ -z $1 || $1 == --* ]]; do | |
27 | - local arg_name="${position_args[$i]}" | |
28 | - local arg_value="$1" | |
29 | - eval "local $arg_name='$arg_value'" | |
30 | - shift | |
31 | - i=$(($i + 1)) | |
32 | - done | |
33 | - | |
34 | - # Set spec values from keyword arguments, if any. The remaining arguments | |
35 | - # are all assumed to be keyword arguments. | |
36 | - while [[ $1 == --* ]]; do | |
37 | - # Remove the `--` at the start. | |
38 | - local arg="${1#--}" | |
39 | - | |
40 | - if [[ $arg != *=* ]]; then | |
41 | - arg="$arg=true" | |
42 | - fi | |
43 | - | |
44 | - # Get the name of the arg and replace the `-`'s to `_`'s. | |
45 | - local arg_name="${${arg%\=*}//-/_}" | |
46 | - | |
47 | - # Get the value of the arg. | |
48 | - local arg_value="${arg#*\=}" | |
49 | - | |
50 | - eval "local $arg_name='$arg_value'" | |
51 | - shift | |
52 | - done | |
22 | + # Parse the given arguments. (Will overwrite the above values). | |
23 | + eval "$(-antigen-parse-args \ | |
24 | + 'url?,loc?;branch:?,no-local-clone?,btype:?' \ | |
25 | + "$@")" | |
53 | 26 | |
54 | 27 | # Check if url is just the plugin name. Super short syntax. |
55 | 28 | if [[ "$url" != */* ]]; then |