Skip to content

Commit

Permalink
refactor: generated Argcfile boilerplate (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored Apr 17, 2024
1 parent c8558ee commit 988acb5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Similar to how Makefile define commands for the `make` tool, Argcscript uses an

See [command runner](https://github.com/sigoden/argc/blob/main/docs/command-runner.md) for more details.

![argcscript](https://github.com/sigoden/argc/assets/4012553/707a3b28-5416-47f1-9d19-788f0135971a)
![argcscript](https://github.com/sigoden/argc/assets/4012553/42dd99bd-958a-49b7-b87d-585f7bd3b317)

## Completions

Expand Down
5 changes: 3 additions & 2 deletions docs/command-runner.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ set -e

# @cmd
build() {
echo To implement command: build
echo TODO build
}

# @cmd
test() {
echo To implement command: test
echo TODO test
}

# See more details at https://github.com/sigoden/argc
eval "$(argc --argc-eval "$0" "$@")"
```

Expand Down
3 changes: 2 additions & 1 deletion src/bin/argc/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ fn generate_boilerplate(args: &[String]) -> String {
r#"
# @cmd
{cmd}() {{
echo To implement command: {cmd}
echo TODO {cmd}
}}
"#
)
Expand All @@ -362,6 +362,7 @@ fn generate_boilerplate(args: &[String]) -> String {
set -e
{tasks}
# See more details at https://github.com/sigoden/argc
eval "$(argc --argc-eval "$0" "$@")"
"#
)
Expand Down
2 changes: 1 addition & 1 deletion tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn create_with_tasks() {
.env("PATH", path_env_var)
.arg("bar")
.assert()
.stdout(predicates::str::contains("To implement command: bar"))
.stdout(predicates::str::contains("TODO bar"))
.success();
}

Expand Down

0 comments on commit 988acb5

Please sign in to comment.