-
Notifications
You must be signed in to change notification settings - Fork 2
Print help when required subcommands are omitted #34
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a8c60d1
Print help on missing required commands
t-kalinowski 7a6f492
Snapshot missing command help as YAML
t-kalinowski 84ace8d
Require command switches by default
t-kalinowski 37307d2
Enforce missing command help with positionals
t-kalinowski 5858e08
Fix unknown command typo handling
t-kalinowski a0acdc5
Render optional commands as optional in help
t-kalinowski cfec596
Group subcommand snapshots by app and invocation
t-kalinowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,202 @@ | ||
| # missing literal command switch prints help | ||
|
|
||
| Code | ||
| yaml12::write_yaml(snapshot) | ||
| Output | ||
| --- | ||
| app: |- | ||
| #!/usr/bin/env Rapp | ||
| #| name: required-command-test | ||
| #| description: Exercise missing command help. | ||
|
|
||
| switch('', | ||
| #| title: List entries | ||
| list = { cat('list called\n') } | ||
| ) | ||
| invocation: | ||
| - usage: $ required-command-test | ||
| output: |- | ||
| Usage: required-command-test <COMMAND> | ||
|
|
||
| Exercise missing command help. | ||
|
|
||
| Commands: | ||
| list List entries | ||
|
|
||
| For help with a specific command, run: `required-command-test <command> --help`. | ||
| - usage: $ required-command-test list | ||
| output: list called | ||
| ... | ||
|
|
||
| # missing command assignment prints help by default | ||
|
|
||
| Code | ||
| yaml12::write_yaml(snapshot) | ||
| Output | ||
| --- | ||
| app: |- | ||
| #!/usr/bin/env Rapp | ||
| #| name: assigned-command-test | ||
| #| description: Exercise missing command help. | ||
|
|
||
| switch(command <- '', | ||
| #| title: List entries | ||
| list = { cat(command, '\n', sep = '') } | ||
| ) | ||
| invocation: | ||
| - usage: $ assigned-command-test | ||
| output: |- | ||
| Usage: assigned-command-test <COMMAND> | ||
|
|
||
| Exercise missing command help. | ||
|
|
||
| Commands: | ||
| list List entries | ||
|
|
||
| For help with a specific command, run: `assigned-command-test <command> --help`. | ||
| - usage: $ assigned-command-test list | ||
| output: list | ||
| ... | ||
|
|
||
| # required false command switch allows missing command | ||
|
|
||
| Code | ||
| yaml12::write_yaml(snapshot) | ||
| Output | ||
| --- | ||
| app: |- | ||
| #!/usr/bin/env Rapp | ||
| #| name: optional-command-test | ||
|
|
||
| #| required: false | ||
| switch(command <- '', | ||
| #| title: List entries | ||
| list = { cat(command, '\n', sep = '') } | ||
| ) | ||
| cat('no command\n') | ||
| invocation: | ||
| - usage: $ optional-command-test | ||
| output: no command | ||
| - usage: $ optional-command-test list | ||
| output: |- | ||
| list | ||
| no command | ||
| - usage: $ optional-command-test --help | ||
| output: |- | ||
| Usage: optional-command-test [<COMMAND>] | ||
|
|
||
| optional-command-test | ||
|
|
||
| Commands: | ||
| list List entries | ||
|
|
||
| For help with a specific command, run: `optional-command-test <command> --help`. | ||
| ... | ||
|
|
||
| # missing command prints help before matching positionals | ||
|
|
||
| Code | ||
| yaml12::write_yaml(snapshot) | ||
| Output | ||
| --- | ||
| app: |- | ||
| #!/usr/bin/env Rapp | ||
| #| name: command-with-positional-test | ||
|
|
||
| #| description: Input path. | ||
| input <- NULL | ||
|
|
||
| switch('', | ||
| #| title: Run command | ||
| run = { cat('run ', input, '\n', sep = '') } | ||
| ) | ||
| cat('no command\n') | ||
| invocation: | ||
| - usage: $ command-with-positional-test data.csv | ||
| output: |- | ||
| Usage: command-with-positional-test <COMMAND> <INPUT> | ||
|
|
||
| command-with-positional-test | ||
|
|
||
| Commands: | ||
| run Run command | ||
|
|
||
| Arguments: | ||
| <INPUT> Input path. | ||
|
|
||
| For help with a specific command, run: `command-with-positional-test <command> --help`. | ||
| - usage: $ command-with-positional-test run data.csv | ||
| output: |- | ||
| run data.csv | ||
| no command | ||
| ... | ||
|
|
||
| # missing nested command prints scoped help | ||
|
|
||
| Code | ||
| yaml12::write_yaml(snapshot) | ||
| Output | ||
| --- | ||
| app: |- | ||
| #!/usr/bin/env Rapp | ||
| #| name: nested-required-command-test | ||
|
|
||
| switch('', | ||
| #| title: Parent command | ||
| parent = { | ||
| switch('', | ||
| #| title: Child command | ||
| child = { cat('child called\n') } | ||
| ) | ||
| } | ||
| ) | ||
| invocation: | ||
| - usage: $ nested-required-command-test parent | ||
| output: |- | ||
| Parent command | ||
|
|
||
| Usage: nested-required-command-test parent <COMMAND> | ||
|
|
||
| Commands: | ||
| child Child command | ||
|
|
||
| For help with a specific command, run: `nested-required-command-test parent <command> --help`. | ||
| - usage: $ nested-required-command-test parent child | ||
| output: child called | ||
| ... | ||
|
|
||
| # optional parent command preserves required child help | ||
|
|
||
| Code | ||
| yaml12::write_yaml(snapshot) | ||
| Output | ||
| --- | ||
| app: |- | ||
| #!/usr/bin/env Rapp | ||
| #| name: optional-parent-required-child-test | ||
|
|
||
| #| required: false | ||
| switch(parent_cmd <- '', | ||
| #| title: Parent command | ||
| parent = { | ||
| switch(child_cmd <- NULL, | ||
| #| title: Child command | ||
| child = { cat('child called\n') } | ||
| ) | ||
| } | ||
| ) | ||
| invocation: | ||
| - usage: $ optional-parent-required-child-test parent | ||
| output: |- | ||
| Parent command | ||
|
|
||
| Usage: optional-parent-required-child-test parent <COMMAND> | ||
|
|
||
| Commands: | ||
| child Child command | ||
|
|
||
| For help with a specific command, run: `optional-parent-required-child-test parent <command> --help`. | ||
| - usage: $ optional-parent-required-child-test parent child | ||
| output: child called | ||
| ... | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| global_opt <- "global_opt_default" | ||
|
|
||
| #| required: false | ||
| switch( | ||
| cmd <- "", | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.