Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve argc-build #339

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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