Commit 973558eee274f9868cf4921aa9745c2f4934aaf2
1 parent
cffa56ed75
Support positional arguments as keyword args.
The positional arguments can also be specified as keyword arguments.
Showing 2 changed files with 9 additions and 1 deletions Side-by-side Diff
antigen.zsh
... | ... | @@ -423,7 +423,10 @@ antigen () { |
423 | 423 | i=$(($i + 1)) |
424 | 424 | done |
425 | 425 | |
426 | - local keyword_args="$(echo "$spec" | cut -d\; -f2 | tr , '\n')" | |
426 | + local keyword_args="$( | |
427 | + echo "$positional_args" | tr , '\n' | sed -r 's/(\??)$/:\1/' | |
428 | + echo "$spec" | cut -d\; -f2 | tr , '\n' | |
429 | + )" | |
427 | 430 | local keyword_args_count="$(echo $keyword_args | awk -F, '{print NF}')" |
428 | 431 | |
429 | 432 | # Set spec values from keyword arguments, if any. The remaining arguments |
tests/arg-parser.t
... | ... | @@ -46,3 +46,8 @@ Provide value for keyword argument, that shouldn't be there. |
46 | 46 | |
47 | 47 | $ parse --no-local-clone=yes |
48 | 48 | No argument required for 'no-local-clone', but provided 'yes'. |
49 | + | |
50 | +Positional argument as a keyword argument. | |
51 | + | |
52 | + $ parse --url=some-url | |
53 | + local url='some-url' |