Skip to content

Commit 2dbb897

Browse files
authored
[doc] Update documents for release (#31)
This PR prepares the repository for the v0.4.0 release by updating documentation/release notes, aligning stringification with Mojo’s `Writable` conventions, and refreshing the pixi workspace configuration/lockfiles. **Changes:** - Remove `__str__` implementations from core structs and rely on `write_to` (`Writable`) for string representations. - Update docs (user manual, changelog, README, planning doc) for Mojo v0.26.2+/v0.4.0 release content. - Bump pixi workspace version and refresh pixi tasks/lockfile to reflect the new environment.
1 parent 24ca712 commit 2dbb897

File tree

10 files changed

+350
-368
lines changed

10 files changed

+350
-368
lines changed

README.md

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A command-line argument parser library for [Mojo](https://www.modular.com/mojo),
77
-->
88

99
[![Version](https://img.shields.io/github/v/tag/forfudan/argmojo?label=version&color=blue)](https://github.com/forfudan/argmojo/releases)
10-
[![Mojo](https://img.shields.io/badge/mojo-0.26.1-orange)](https://docs.modular.com/mojo/manual/)
10+
[![Mojo](https://img.shields.io/badge/mojo-0.26.2-orange)](https://docs.modular.com/mojo/manual/)
1111
[![pixi](https://img.shields.io/badge/pixi%20add-argmojo-brightgreen)](https://prefix.dev/channels/modular-community/packages/argmojo)
1212
[![User manual](https://img.shields.io/badge/user-manual-purple)](https://github.com/forfudan/argmojo/wiki)
1313

@@ -51,8 +51,34 @@ ArgMojo provides a builder-pattern API for defining and parsing command-line arg
5151
- **Append / collect action**: `--tag x --tag y` collects repeated options into a list with `.append()`
5252
- **One-required groups**: require at least one argument from a group (e.g., must provide `--json` or `--yaml`)
5353
- **Value delimiter**: `--env dev,staging,prod` splits by delimiter into a list with `.delimiter[","]()`
54-
- **Multi-value options (nargs)**: `--point 10 20` consumes N consecutive values with `.nargs(N)`
54+
- **Multi-value options (nargs)**: `--point 10 20` consumes N consecutive values with `.number_of_values[N]()`
55+
- **Key-value map options**: `--define CC=gcc --define CXX=g++` collects key=value pairs with `.map_option()`
56+
- **Numeric range validation**: `--level 5` checked against `[min, max]` bounds with `.range[1, 10]()`; optional clamping with `.clamp()`
57+
- **Conditional requirements**: `--output` required when `--save` is present
58+
- **Aliases**: alternative long names (e.g., `--colour` and `--color`) with `.alias_name["color"]()`
59+
- **Deprecated arguments**: emit a warning but continue parsing
60+
- **Custom tips**: add tip lines below the help message
61+
- **Mutual implication**: `--debug` automatically sets `--verbose` with `.implies()`
62+
- **Subcommands**: hierarchical commands (`app search`, `app init`), nested subcommands (`app remote add`), persistent (global) flags, subcommand aliases, hidden subcommands
5563
- **Shell completion script generation**: `generate_completion("bash"|"zsh"|"fish")` produces a complete tab-completion script for your CLI
64+
- **Typo suggestions**: Levenshtein-distance "did you mean …?" for misspelled options and subcommands
65+
- **Interactive prompting**: `.prompt()` to interactively ask for missing values
66+
- **Password / masked input**: `.password()` to hide typed input during prompts
67+
- **Confirmation option**: `confirmation_option()` to add a `--yes`/`-y` skip-confirmation flag
68+
- **Argument parents**: `add_parent()` to share argument definitions across commands
69+
- **Custom usage line**: `usage()` to override the auto-generated usage string
70+
- **Response files**: `@args.txt` expansion (temporarily disabled due to a Mojo compiler bug)
71+
- **CJK-aware help alignment**: CJK characters treated as 2-column-wide
72+
- **CJK full-width auto-correction**: fullwidth `--verbose``--verbose` with a warning
73+
- **CJK punctuation detection**: em-dash `——verbose``--verbose`
74+
- **Argument groups**: `.group["Network"]()` to group arguments under dedicated help sections
75+
- **Default-if-no-value**: `--compress` uses a fallback; `--compress=bzip2` overrides
76+
- **Require equals syntax**: `--key=value` required, `--key value` rejected
77+
- **Remainder positional**: `.remainder()` consumes all remaining tokens
78+
- **Allow hyphen values**: `.allow_hyphen_values()` accepts `-` as a regular value (stdin convention)
79+
- **Partial parsing**: `parse_known_arguments()` collects unrecognised options instead of erroring
80+
- **Compile-time validation**: builder parameters validated at `mojo build` time via `comptime assert`
81+
- **Registration-time validation**: group constraint typos caught when the program starts, not when the user runs it
5682

5783
---
5884

@@ -62,6 +88,8 @@ My goal is to provide a Mojo-idiomatic argument parsing library that can be easi
6288

6389
## Installation
6490

91+
### Package Manager
92+
6593
ArgMojo is available in the modular-community `https://repo.prefix.dev/modular-community` package repository. To access this repository, add it to your `channels` list in your `pixi.toml` file:
6694

6795
```toml
@@ -75,17 +103,14 @@ Then, you can install ArgMojo using any of these methods:
75103
1. In the `mojoproject.toml` file of your project, add the following dependency:
76104

77105
```toml
78-
argmojo = "==0.3.0"
106+
argmojo = "*"
79107
```
80108

81109
Then run `pixi install` to download and install the package.
82110

83-
The following table summarizes the package versions and their corresponding Mojo versions:
111+
### Using mojopkg
84112

85-
| `argmojo` version | `mojo` version | package manager |
86-
| ----------------- | -------------- | --------------- |
87-
| 0.1.0 | ==0.26.1 | pixi |
88-
| 0.3.0 | ==0.26.1 | pixi |
113+
The package manager may not be up to date with the latest ArgMojo release. If you want to use the latest version, you can download the `mojopkg` file from the [latest release](https://github.com/forfudan/argmojo/releases) and include it in your project directory.
89114

90115
## Quick Start
91116

@@ -95,7 +120,7 @@ Here is a simple example of how to use ArgMojo in a Mojo program. See `examples/
95120
from argmojo import Argument, Command
96121

97122

98-
fn main() raises:
123+
def main() raises:
99124
var app = Command("mgrep", "Search for PATTERN in each FILE.", version="1.0.0")
100125

101126
# Positional arguments
@@ -144,10 +169,12 @@ For detailed explanations and more examples of every feature, see the **[User Ma
144169

145170
ArgMojo ships with two complete example CLIs:
146171

147-
| Example | File | Features |
148-
| ------------------------ | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
149-
| `mgrep` — simulated grep | `examples/mgrep.mojo` | Positional args, flags, count flags, negatable flags, choices, value_name, append/collect, value delimiter, nargs, mutually exclusive groups, required-together groups, conditional requirements, numeric range, key-value map, aliases, deprecated args, hidden args, negative-number passthrough, `--` stop marker, custom tips |
150-
| `mgit` — simulated git | `examples/mgit.mojo` | Subcommands (clone/init/add/commit/push/pull/log/remote/branch/diff/tag/stash), nested subcommands (remote add/remove/rename/show), persistent (global) flags, per-command args, mutually exclusive groups, choices, aliases, deprecated args, custom tips, shell completion script generation |
172+
| Example | File | Features |
173+
| ------------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
174+
| `mgrep` — simulated grep | `examples/mgrep.mojo` | Positional args, flags, count flags, negatable flags, choices, value_name, append/collect, value delimiter, nargs, mutually exclusive groups, required-together groups, conditional requirements, numeric range, key-value map, aliases, deprecated args, hidden args, negative-number passthrough, `--` stop marker, custom tips |
175+
| `mgit` — simulated git | `examples/mgit.mojo` | Subcommands (clone/init/add/commit/push/pull/log/remote/branch/diff/tag/stash), nested subcommands (remote add/remove/rename/show), persistent (global) flags, per-command args, mutually exclusive groups, choices, aliases, deprecated args, custom tips, shell completion script generation |
176+
| `demo` — feature showcase | `examples/demo.mojo` | Comprehensive showcase of all ArgMojo features in a single CLI |
177+
| `yu` — Chinese CLI | `examples/yu.mojo` | CJK-aware help formatting, full-width auto-correction, CJK punctuation detection |
151178

152179
Build both example binaries:
153180

@@ -232,10 +259,14 @@ pixi run clean
232259
```txt
233260
argmojo/
234261
├── docs/ # Documentation
262+
│ ├── argmojo_overall_planning.md # Planning document and feature matrix
263+
│ ├── changelog.md # Release changelog
235264
│ └── user_manual.md # User manual with detailed examples
236265
├── examples/
266+
│ ├── demo.mojo # Comprehensive feature showcase
237267
│ ├── mgrep.mojo # grep-like CLI (no subcommands)
238-
│ └── mgit.mojo # git-like CLI (with subcommands)
268+
│ ├── mgit.mojo # git-like CLI (with subcommands)
269+
│ └── yu.mojo # Chinese-language CLI (CJK features)
239270
├── src/
240271
│ └── argmojo/ # Main package
241272
│ ├── __init__.mojo # Package exports

docs/argmojo_overall_planning.md

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ At the moment, Mojo does not have a mature command-line argument parsing library
1010

1111
## 2. Cross-Language Research Summary
1212

13-
This section summarises the key design patterns and features from well-known arg parsers across multiple languages. The goal is to extract **universally useful ideas** that are feasible in Mojo 0.26.1, and to exclude features that depend on language-specific capabilities (macros, decorators, reflection, closures-as-first-class) that Mojo does not yet provide.
13+
This section summarises the key design patterns and features from well-known arg parsers across multiple languages. The goal is to extract **universally useful ideas** that are feasible in Mojo 0.26.2, and to exclude features that depend on language-specific capabilities (macros, decorators, reflection, closures-as-first-class) that Mojo does not yet provide.
1414

1515
### 2.1 Libraries Surveyed
1616

@@ -55,7 +55,7 @@ These features appear across multiple libraries and depend only on string operat
5555
| Key-value map (`-Dkey=val`) ||||| Java `-D`, Docker `-e` | **Done** |
5656
| Aliases for long names ||||| | **Done** |
5757
| Deprecated arguments | ✓ (3.13) |||| | **Done** |
58-
| Negative number passthrough ||| || Essential for `decimo` | **Done** |
58+
| Negative number / stdin `` ||| || `allow_hyphen_values()` | **Done** |
5959
| Subcommands ||||| | **Done** |
6060
| Auto-added `help` subcommand ||||| git, cargo, kubectl | **Done** |
6161
| Persistent (global) flags ||||| git `--no-pager` etc. | **Done** |
@@ -70,13 +70,11 @@ These features appear across multiple libraries and depend only on string operat
7070
| Interactive prompting ||||| | **Done** |
7171
| Password / masked input ||||| | **Done** |
7272
| Confirmation (`--yes` / `-y`) ||||| | **Done** |
73-
| Pre/Post run hooks ||||| | Phase 5 |
7473
| REMAINDER number_of_values ||||| | **Done** |
7574
| Partial parsing (known args) ||||| | **Done** |
7675
| Require equals syntax ||||| | **Done** |
7776
| Default-if-no-value ||||| | **Done** |
7877
| Mutual implication (`implies`) ||||| ArgMojo unique feature | **Done** |
79-
| Stdin value (`-` convention) ||||| Unix convention | Phase 5 |
8078
| Shell completion script generation ||||| bash / zsh / fish | **Done** |
8179
| Argument groups in help ||||| | **Done** |
8280
| Value-name wrapping control ||||| clap, cargo, pixi, git | **Done** |
@@ -86,6 +84,7 @@ These features appear across multiple libraries and depend only on string operat
8684
| Typed retrieval (`get_int()` etc.) ||||| | **Done** |
8785
| Comptime `StringLiteral` params ||||| clap derive macros | **Done** |
8886
| Registration-time name validation ||||| clap panic on unknown ID | **Done** |
87+
| Pre/Post run hooks ||||| | Phase unknown |
8988
| `Parseable` trait for type params ||||| | Phase unknown |
9089
| Derive / struct-based schema ||||| Requires Mojo macros | Phase unknown |
9190
| Enum → type mapping (real enums) ||||| Requires reflection | Phase unknown |
@@ -110,9 +109,9 @@ These features appear across multiple libraries and depend only on string operat
110109
Mojo provides `sys.argv()` to access command-line arguments:
111110

112111
```mojo
113-
from sys import argv
112+
from std.sys import argv
114113
115-
fn main():
114+
def main():
116115
var args = argv()
117116
for i in range(len(args)):
118117
print("arg[", i, "] =", args[i])
@@ -151,27 +150,14 @@ src/argmojo/
151150
├── parse_result.mojo # ParseResult struct — parsed values
152151
└── utils.mojo # Internal utilities — ANSI colours, display helpers
153152
tests/
154-
├── test_parse.mojo # Core parsing tests (flags, values, shorts, etc.)
155-
├── test_groups.mojo # Group constraint tests (exclusive, conditional, etc.)
156-
├── test_collect.mojo # Collection feature tests (append, delimiter, number_of_values)
157-
├── test_help.mojo # Help output tests (formatting, colours, alignment)
158-
├── test_extras.mojo # Range, map, alias, deprecated tests
159-
├── test_subcommands.mojo # Subcommand tests (dispatch, help sub, unknown sub, etc.)
160-
├── test_negative_numbers.mojo # Negative number passthrough tests
161-
├── test_persistent.mojo # Persistent (global) flag tests
162-
├── test_typo_suggestions.mojo # Levenshtein typo suggestion tests
163-
├── test_completion.mojo # Shell completion script generation tests
164-
├── test_implies.mojo # Mutual implication and cycle detection tests
165-
├── test_const_require_equals.mojo # default_if_no_value and require_equals tests
166-
├── test_response_file.mojo # response file (@args.txt) expansion tests
167-
├── test_remainder_known.mojo # remainder, parse_known_arguments, allow_hyphen_values tests
168-
├── test_fullwidth.mojo # full-width → half-width auto-correction tests
169-
├── test_groups_help.mojo # argument groups in help + value_name wrapping tests
170-
├── test_prompt.mojo # interactive prompting tests
171-
├── test_parents.mojo # argument parents (shared definitions) tests
172-
├── test_confirmation.mojo # confirmation option (--yes / -y) tests
173-
├── test_password.mojo # password / masked input tests
174-
└── test_usage.mojo # usage line customisation tests
153+
├── test_parse.mojo # Core parsing + negative number passthrough tests
154+
├── test_options.mojo # default_if_no_value, require_equals, range, clamp, map, aliases, deprecated, remainder, parse_known, collection tests
155+
├── test_groups.mojo # Mutually exclusive, required-together, one-required, conditional, implies, argument groups in help, value_name wrapping tests
156+
├── test_help.mojo # Help formatting, ANSI colours, CJK alignment, NO_COLOR, custom usage, fullwidth correction tests
157+
├── test_subcommands.mojo # Subcommand dispatch, persistent/global flags, argument parents tests
158+
├── test_completion.mojo # Shell completion (bash/zsh/fish) + Levenshtein typo suggestion tests
159+
├── test_interactive.mojo # Interactive prompting, password/masked input, confirmation tests
160+
└── test_response_file.mojo # Response file (@args.txt) expansion tests (⚠ disabled due to compiler bug)
175161
examples/
176162
├── demo.mojo # comprehensive showcase of all ArgMojo features
177163
├── mgrep.mojo # grep-like CLI example (no subcommands)
@@ -253,7 +239,7 @@ examples/
253239
```mojo
254240
from argmojo import Command, Argument
255241
256-
fn main() raises:
242+
def main() raises:
257243
var command = Command("demo", "A CJK-aware text search tool which supports pinyin and Yuhao IME")
258244
259245
# Positional arguments

0 commit comments

Comments
 (0)