Hey Magicans and Pythonistas!
I’m sharing ArgMojo, a command-line argument parser for Mojo, inspired by Python’s argparse, Rust’s clap, and Go’s cobra.
If you’ve ever used Python’s argparse, Rust’s clap, or Go’s cobra, you know how essential a good arg parser is for any CLI tool. I’m working on a CLI-based Chinese character search engine and a CLI calculator for Decimo, so I needed one for Mojo — and that’s how ArgMojo was born.

Demo: Shell tab-completion powered by ArgMojo
Installation
Available on modular-community:
pixi add argmojo
What it does
ArgMojo provides a builder-pattern API for defining and parsing CLI arguments. Core features include:
Parsing — long/short options, boolean flags, positional args, defaults, required args, -- stop marker, short flag merging (-abc), attached short values (-ofile), prefix matching (--verb → --verbose)
Value handling — choices validation, count flags (-vvv), negatable flags (--color / --no-color), append/collect (--tag x --tag y), value delimiter (--env a,b,c), multi-value nargs, key-value maps, numeric range validation
Groups — mutually exclusive, required-together, one-required, conditional requirements
Subcommands — hierarchical commands with nesting (e.g., git remote add), persistent (global) flags, auto-registered help subcommand
Help & UX — auto-generated --help with pixi-style ANSI colours, --version, metavar, hidden args, aliases, deprecated args, custom tips
Demo
The repo ships with two complete example CLIs — a simulated grep (single command, showcasing all value/group features) and a simulated git (12 subcommands with nesting) — so you can see everything in action.
Here’s what ./mgit clone looks like:
The design is inspired by argparse/clap/cobra, but adapted to fit Mojo’s current capabilities. It is just structs and builder methods. I did a cross-language survey of some major CLI libraries, so the feature set is deliberate. In future, I plan to add some features that may be convenient for CJK users.
Your feedback are very welcome. Just raise an issue if you find any bug or have any suggestion. Thanks for very much ![]()
