Skip to content

Commit

Permalink
chore: update readme and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed Nov 12, 2023
1 parent abe741e commit 93ec2db
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Argcfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]})" ;;
Expand Down
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,8 @@ Define a positional argument.
# @arg vd+ required + multiple
# @arg vna <PATH> 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
```

Expand All @@ -147,16 +141,9 @@ Define a option.
# @option --oe+ required + multi-occurs
# @option --ona <PATH> value notation
# @option --onb <CMD> <FILE> two-args value notations
# @option --onc <CMD> <FILE+> 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
```

Expand All @@ -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
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions examples/subcmds.sh → examples/nested.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ cmd::foo() { :; }
cmd::bar() { :; }
# @cmd
cmd::bar::baz() { :; }
# @cmd
cmd::bar::qux() { :; }

eval "$(argc --argc-eval "$0" "$@")"
44 changes: 25 additions & 19 deletions examples/options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
:;
Expand All @@ -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*
Expand All @@ -41,10 +42,20 @@ flags() {
# @option -ona <PATH>
# @option -oca[a|b]
# @option -ofa[`_choice_fn`]
1dash() {
single-hyphen() {
:;
}

# @cmd All kinds of value noataion
# @option --oa <FILE> one file value
# @option --ob <DIR> one dir value
# @option --oc <PATH> one path value
# @option --oe <VALUE*> multi values, zero or more
# @option --of <VALUE+> multi values, one or more
# @option --og <VALUE?> zero or one
value-notation() {
:;
}

# @cmd All kind of options
# @option +oa
Expand All @@ -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 <PATH>
# @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() {
:;
}

Expand Down
8 changes: 4 additions & 4 deletions examples/parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" "$@")"

0 comments on commit 93ec2db

Please sign in to comment.