Skip to content

Commit

Permalink
refactor: improve argc-build (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored Jun 10, 2024
1 parent c47abcb commit 5182626
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
7 changes: 5 additions & 2 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,15 @@ fn build_root(cmd: &Command, wrap_width: Option<usize>) -> String {

format!(
r#"# ARGC-BUILD {{
# This block was generated by argc (https://github.com/sigoden/argc)
# This block was generated by argc (https://github.com/sigoden/argc).
# Modifying it manually is not recommended
_argc_run() {{
if [[ "${{1:-}}" == "___internal___" ]]; then
_argc_die "error: no supported param"
_argc_die "error: unsupported ___internal___ command"
fi
if [[ "${{OS:-}}" == "Windows_NT" ]] && [[ -n "${{MSYSTEM:-}}" ]]; then
set -o igncr
fi
argc__args=("$(basename "$0" .sh)" "$@")
argc__positionals=()
Expand Down
4 changes: 1 addition & 3 deletions tests/snapshots/integration__hook_fn__hook_param_fn.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ _argc_after
exit

# BUILD_OUTPUT
error: no supported param


error: unsupported ___internal___ command
8 changes: 3 additions & 5 deletions tests/snapshots/integration__param_fn__case1.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _choice_fn
exit

# RUN_OUTPUT
error: no supported param
error: unsupported ___internal___ command

************ RUN ************
prog ___internal___ _choice_fn prog test1 --cc
Expand All @@ -29,7 +29,7 @@ _choice_fn
exit

# RUN_OUTPUT
error: no supported param
error: unsupported ___internal___ command

************ RUN ************
prog ___internal___ _choice_fn prog test1 -a --oa oa --cc
Expand All @@ -47,6 +47,4 @@ _choice_fn
exit

# RUN_OUTPUT
error: no supported param


error: unsupported ___internal___ command
14 changes: 6 additions & 8 deletions tests/snapshots/integration__param_fn__case2.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _choice_fn
exit

# RUN_OUTPUT
error: no supported param
error: unsupported ___internal___ command

************ RUN ************
prog ___internal___ _choice_fn prog cmd_multi_arg_with_choice_fn
Expand All @@ -28,7 +28,7 @@ _choice_fn ''
exit

# RUN_OUTPUT
error: no supported param
error: unsupported ___internal___ command

************ RUN ************
prog ___internal___ _choice_fn prog cmd_multi_arg_with_choice_fn v1
Expand All @@ -43,7 +43,7 @@ _choice_fn v1
exit

# RUN_OUTPUT
error: no supported param
error: unsupported ___internal___ command

************ RUN ************
prog ___internal___ _choice_fn prog cmd_multi_arg_with_choice_fn v1
Expand All @@ -58,7 +58,7 @@ _choice_fn v1 ''
exit

# RUN_OUTPUT
error: no supported param
error: unsupported ___internal___ command

************ RUN ************
prog ___internal___ _choice_fn prog cmd_multi_arg_with_choice_fn v1 v2
Expand All @@ -73,7 +73,7 @@ _choice_fn v1 v2
exit

# RUN_OUTPUT
error: no supported param
error: unsupported ___internal___ command

************ RUN ************
prog ___internal___ _choice_fn prog cmd_multi_arg_with_choice_fn v1 v2
Expand All @@ -88,6 +88,4 @@ _choice_fn v1 v2 ''
exit

# RUN_OUTPUT
error: no supported param


error: unsupported ___internal___ command
14 changes: 6 additions & 8 deletions tests/snapshots/integration__param_fn__case3.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _choice_fn
exit

# RUN_OUTPUT
error: no supported param
error: unsupported ___internal___ command

************ RUN ************
prog ___internal___ _choice_fn prog
Expand All @@ -27,7 +27,7 @@ _choice_fn ''
exit

# RUN_OUTPUT
error: no supported param
error: unsupported ___internal___ command

************ RUN ************
prog ___internal___ _choice_fn prog v1
Expand All @@ -41,7 +41,7 @@ _choice_fn v1
exit

# RUN_OUTPUT
error: no supported param
error: unsupported ___internal___ command

************ RUN ************
prog ___internal___ _choice_fn prog v1
Expand All @@ -56,7 +56,7 @@ _choice_fn v1 ''
exit

# RUN_OUTPUT
error: no supported param
error: unsupported ___internal___ command

************ RUN ************
prog ___internal___ _choice_fn prog v1 v2
Expand All @@ -71,7 +71,7 @@ _choice_fn v1 v2
exit

# RUN_OUTPUT
error: no supported param
error: unsupported ___internal___ command

************ RUN ************
prog ___internal___ _choice_fn prog v1 v2
Expand All @@ -86,6 +86,4 @@ _choice_fn v1 v2
exit

# RUN_OUTPUT
error: no supported param


error: unsupported ___internal___ command

0 comments on commit 5182626

Please sign in to comment.