diff --git a/Argcfile.sh b/Argcfile.sh index bb2285cf..48642bce 100644 --- a/Argcfile.sh +++ b/Argcfile.sh @@ -31,7 +31,7 @@ setup-shell() { bash) echo "source <(argc --argc-completions bash ${argc_cmds[@]})" ;; elvish) echo "eval (argc --argc-completions elvish ${argc_cmds[@]} | slurp)" ;; fish) echo "argc --argc-completions fish ${argc_cmds[@]} | source" ;; - nushell) echo "argc --argc-completions nushell ${argc_cmds[@]} | save -f /tmp/argc.nu"$'\n'"source /tmp/argc.nu" ;; + nushell) echo "argc --argc-completions nushell ${argc_cmds[@]} | save -f argc.nu"$'\n'"source argc.nu" ;; powershell) echo "argc --argc-completions powershell ${argc_cmds[@]} | Out-String | Invoke-Expression" ;; xonsh) echo "exec(\$(argc --argc-completions xonsh ${argc_cmds[@]}))" ;; zsh) echo "source <(argc --argc-completions zsh ${argc_cmds[@]})" ;; diff --git a/README.md b/README.md index 600da566..bd8b5e4d 100644 --- a/README.md +++ b/README.md @@ -119,14 +119,8 @@ Define a positional argument. # @arg vd+ required + multiple # @arg vna value notation # @arg vda=a default -# @arg vdb=`_default_fn` default from fn # @arg vca[a|b] choice # @arg vcb[=a|b] choice + default -# @arg vcc*[a|b] multiple + choice -# @arg vcd+[a|b] required + multiple + choice -# @arg vfa[`_choice_fn`] choice from fn -# @arg vfb[?`_choice_fn`] choice from fn + no validation -# @arg vfc*[`_choice_fn`] multiple + choice from fn # @arg vx~ capture all remaining args ``` @@ -147,16 +141,9 @@ Define a option. # @option --oe+ required + multi-occurs # @option --ona value notation # @option --onb two-args value notations -# @option --onc unlimited-args value notations # @option --oda=a default -# @option --odb=`_default_fn` default from fn # @option --oca[a|b] choice # @option --ocb[=a|b] choice + default -# @option --occ*[a|b] multi-occurs + choice -# @option --ocd+[a|b] required + multi-occurs + choice -# @option --ofa[`_choice_fn`] choice from fn -# @option --ofb[?`_choice_fn`] choice from fn + no validation -# @option --ofc*[`_choice_fn`] multi-occurs + choice from fn # @option --oxa~ capture all remaining args ``` @@ -174,7 +161,6 @@ Define a flag. A flag is an option of boolean type, and is always false by defau # @flag -b --fb short # @flag -c short only # @flag --fd* multi-occurs -# @flag -e --fe* short + multi-occurs ``` ### @alias diff --git a/examples/wrap_help.sh b/examples/details.sh similarity index 100% rename from examples/wrap_help.sh rename to examples/details.sh diff --git a/examples/subcmds.sh b/examples/nested.sh similarity index 82% rename from examples/subcmds.sh rename to examples/nested.sh index 8200387d..62551ccd 100755 --- a/examples/subcmds.sh +++ b/examples/nested.sh @@ -6,5 +6,7 @@ cmd::foo() { :; } cmd::bar() { :; } # @cmd cmd::bar::baz() { :; } +# @cmd +cmd::bar::qux() { :; } eval "$(argc --argc-eval "$0" "$@")" \ No newline at end of file diff --git a/examples/options.sh b/examples/options.sh index 53c92ef3..e66f3517 100755 --- a/examples/options.sh +++ b/examples/options.sh @@ -17,6 +17,7 @@ # @option --ofa[`_choice_fn`] choice from fn # @option --ofb[?`_choice_fn`] choice from fn + no validation # @option --ofc*[`_choice_fn`] multi-occurs + choice from fn +# @option --ofd*,[`_choice_fn`] multi-occurs + choice from fn + comma separated list # @option --oxa~ capture all remaining args options() { :; @@ -32,7 +33,7 @@ flags() { :; } -# @cmd Flags or options with single dash +# @cmd Flags or options with single hyphen # @flag -fa # @flag -b -fb # @flag -fd* @@ -41,10 +42,20 @@ flags() { # @option -ona # @option -oca[a|b] # @option -ofa[`_choice_fn`] -1dash() { +single-hyphen() { :; } +# @cmd All kinds of value noataion +# @option --oa one file value +# @option --ob one dir value +# @option --oc one path value +# @option --oe multi values, zero or more +# @option --of multi values, one or more +# @option --og zero or one +value-notation() { + :; +} # @cmd All kind of options # @option +oa @@ -65,39 +76,34 @@ flags() { # @option +ofa[`_choice_fn`] choice from fn # @option +ofb[?`_choice_fn`] choice from fn + no validation # @option +ofc*[`_choice_fn`] multi-occurs + choice from fn +# @option +ofd*,[`_choice_fn`] multi-occurs + choice from fn + comma separated list # @option +oxa~ capture all remaining args -plus_options() { +plus-options() { :; } - # @cmd All kind of flags # @flag +fa # @flag +b +fb short # @flag +c short only # @flag +fd* multi-occurs # @flag +e +fe* short + multi-occurs -plus_flags() { +plus-flags() { :; } -# @cmd Flags or options with single dash -# @flag +fa -# @flag +b +fb -# @flag +fd* -# @option +oa -# @option +od* -# @option +ona -# @option +oca[a|b] -# @option +ofa[`_choice_fn`] -plus_1dash() { +# @cmd Mixed `-` and `+` options +# @option +a -a +# @option -b +b +# @option +c --c +mix-options() { :; } - -# @cmd Mixed `-` and `+` options -# @option +b --ob -mix_options() { +# @cmd Prefixed option +# @option -X-*[`_choice_fn`] prefixied + multi-occurs + choice from fn +# @option +X-*[`_choice_fn`] prefixied + multi-occurs + choice from fn +prefixed-option() { :; } diff --git a/examples/parallel.sh b/examples/parallel.sh index da9330b1..79db2675 100644 --- a/examples/parallel.sh +++ b/examples/parallel.sh @@ -21,19 +21,19 @@ cmd2() { # @cmd # @option --oa foo() { - argc --argc-parallel "$0" cmd1 abc ::: _fn ::: cmd2 + argc --argc-parallel "$0" cmd1 abc ::: func ::: cmd2 } # @cmd # @option --oa bar() { cmd1 abc - _fn + func cmd2 } -_fn() { - echo fn +func() { + echo func } eval "$(argc --argc-eval "$0" "$@")" \ No newline at end of file