Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for overriding ArgMojo’s auto-generated usage line with a fully custom, git-style usage string, and documents/tests the new capability.
Changes:
- Add
Command.usage(text)and_custom_usagestorage, used by both help generation and plain-text usage hints. - Add a new test suite validating custom vs default usage behavior and copy preservation.
- Update documentation (user manual, changelog, planning docs) and wire the new test into
pixi.toml.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/argmojo/command.mojo |
Introduces _custom_usage, usage(), and integrates custom usage into help/usage rendering. |
tests/test_usage.mojo |
New tests for custom usage in help (plain/colored), default usage fallback, copy behavior, and parsing unaffected. |
pixi.toml |
Adds the new test file to the test task pipeline. |
docs/user_manual.md |
Documents command.usage("...") and updates reference tables/TOC. |
docs/changelog.md |
Adds a changelog entry for usage customization (currently has a formatting/content issue). |
docs/argmojo_overall_planning.md |
Marks usage customization as implemented and lists the new test file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
docs/user_manual.md
Outdated
Comment on lines
+3314
to
+3322
| Usage: git [-v | --version] [-h | --help] [-C <path>] <command> [<args>] | ||
|
|
||
| The stupid content tracker | ||
|
|
||
| Options: | ||
| -v, --verbose Verbose output | ||
| -C <path> Run as if started in <path> | ||
| -h, --help Print help | ||
| -V, --version Print version |
| assert_equal(result.get_string("file"), "input.txt") | ||
| assert_true(result.get_flag("verbose"), msg="--verbose should work") | ||
|
|
||
|
|
docs/changelog.md
Outdated
Comment on lines
+28
to
+29
| 16. **Confirmation option.** Add `confirmation_option()` and `confirmation_option["prompt"]()` builder methods on `Command`. | ||
| 17. **Usage line customisation.** Add `usage(text)` method on `Command`. When set, the given text replaces the auto-generated `Usage: myapp [OPTIONS] ...` line in both `--help` output and error messages. This lets you write git-style usage strings like `git [-v | --version] [-h | --help] [-C <path>] <command> [<args>]`. When not set, the default auto-generated usage line is used. When enabled, the command automatically registers a `--yes` / `-y` flag and prompts the user for confirmation after parsing (and after interactive prompting, if any). If the user does not confirm (`y`/`yes`), the command aborts with an error. Passing `--yes` or `-y` on the command line skips the prompt entirely. When stdin is not interactive (piped input, `/dev/null`), the command aborts gracefully. This is equivalent to Click's `confirmation_option` decorator (PR #26). |
docs/user_manual.md
Outdated
|
|
||
| ## Usage Line Customisation | ||
|
|
||
| By default, ArgMojo generates usage lines like `Usage: myapp [OPTIONS] <PATTERN>` — showing `[OPTIONS]` for named arguments and listing each positional. This convention (shared by clap, cobra, and Click) works well for most CLIs. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds support for overriding ArgMojo’s auto-generated usage line with a fully custom, git-style usage string, and documents/tests the new capability.
Changes:
Command.usage(text)and_custom_usagestorage, used by both help generation and plain-text usage hints.pixi.toml.