20260404 (v0.5.0)
ArgMojo v0.5.0 introduces the struct-based declarative API — define a Parsable struct with typed wrapper fields (Option, Flag, Positional, Count), call MyArgs.parse(), and get typed results. The declarative API coexists with the existing builder API and bridges between them via to_command() / parse_from_command(). This release also adds asterisk-masked password input and reorganises internal modules.
ArgMojo v0.5.0 targets Mojo v0.26.2.
⭐️ New in v0.5.0
- Declarative API core —
Parsabletrait with compile-time reflection over wrapper-typed fields. Conforming structs need only declare fields and providedescription(); all parsing, Command-building, and write-back methods are provided as trait defaults (PR #34, #35, #37, #40). - Wrapper types —
Option[T, ...],Flag[...],Positional[T, ...],Count[...]parametric structs encode CLI metadata as compile-time parameters. Conform to the internalArgumentLiketrait withadd_to_command()/read_from_result()hooks (PR #34). - Auto-initialisation —
Parsable.__init__usesmark_initialized+comptime for+UnsafePointer.init_pointee_moveto default-construct all fields via reflection. Users never need to write__init__(PR #37). - Hybrid bridge —
to_command()reflects aParsablestruct into an ownedCommandfor builder-level customisation;parse_from_command(cmd^)parses back into a typed struct (PR #35, #40). - Dual-return parsing —
parse_full()returnsTuple[Self, ParseResult]for workflows that need both typed struct fields and rawParseResultaccess (e.g. subcommand dispatch).parse_full_from_command(cmd^)does the same from a pre-configured Command (PR #40, #42). - Subcommand support —
subcommands()hook onParsablereturnsList[Command]; called automatically byto_command()for recursive tree assembly.run(self)method for leaf command execution.from_parse_result()for typed write-back from subcommand results (PR #39, #43). - Asterisk-masked password input —
.password[True]()onArgumentechoes*for each keystroke (sudo-rs style), complementing the existing.password()which hides input entirely. Uses raw terminal mode with ICANON/ISIG disabled (PR #32).
🦋 Changed in v0.5.0
- Remove
Argalias forArgumentand dropArgumentLikefrom the public export list. The public API now exports:Argument,Command,ParseResult,Parsable,Option,Flag,Positional,Count(PR #42). subcommands()hook signature changed fromsubcommands(mut cmd: Command) raisestosubcommands() raises -> List[Command]— returns a list of Commands instead of mutating one (PR #43).- Reorganise
ArgumentandCommandsource files into clearly grouped internal sections for readability (PR #33).
📚 Documentation and testing in v0.5.0
- Add
docs/declarative_api_planning.md— comprehensive design document for the declarative API (PR #33). - Add 4 declarative examples:
search.mojo(pure declarative),deploy.mojo(hybrid),convert.mojo(full parse + extra builder args),jomo.mojo(subcommands with hybrid tree) (PR #41). - Add 4 test modules:
test_wrappers.mojo(wrapper defaults, copy/move,Flag.__bool__),test_declarative.mojo(to_command, parse_args, from_parse_result),test_hybrid.mojo(builder customisation, mutually exclusive, implies, configure pattern),test_subcommands_declarative.mojo(flat/nested subcommands, run() dispatch, dual return) (PR #38, #39). - Add
test_interactive.mojofor interactive prompting edge cases (PR #33). - Add method matrix table to README, user manual, and planning doc.
- Update README with declarative API Quick Start, examples table, and project structure.
- Update user manual with declarative API usage guide, full-parse section, and API summary.
What's Changed
- [core] Enable asterisk-masked password input by @forfudan in #32
- [doc] Add a planning file for declarative API + Reorganize
Command/Argumentinternals for clearer grouping by @forfudan in #33 - [core][declarative] Implement argument wrappers and Parsable trait by @forfudan in #34
- [core][declarative] Implement
Parsablereflection, trait methods, and example by @forfudan in #35 - [core][declarative] Use
rebindinstead ofUnsafePointerin argument wrapper write-back logic by @forfudan in #36 - [core][declarative] Default-initialize all fields via reflection in
__init__ofParsabletrait by @forfudan in #37 - [core][declarative] Add tests for hybrid declarative + builder API by @forfudan in #38
- [core][declarative] Add tests for declarative subcommands by @forfudan in #39
- [core][declarative] Consolidate Parsable trait functions into methods by @forfudan in #40
- [core][declarative] Add more examples of declarative API by @forfudan in #41
- [core][declarative][doc] Enrich documentation and rename some methods by @forfudan in #42
- [core][declarative] Update
to_commandso that it returns a list ofCommandby @forfudan in #43 - [declarative][doc] Standardize
Parsableparsing method names + Update documents for release by @forfudan in #44
Full Changelog: v0.4.0...v0.5.0