Skip to content

ArgMojo v0.1.0

Choose a tag to compare

@forfudan forfudan released this 24 Feb 19:57
· 69 commits to main since this release

20260224 (v0.1.0)

ArgMojo v0.1.0 is the initial release of a command-line argument parser library for Mojo. It provides a builder-pattern API for defining and parsing CLI arguments, inspired by Python's argparse, Rust's clap, and Go's cobra.

ArgMojo v0.1.0 is compatible with Mojo v0.26.1.

⭐️ Features

  • Long and short options: --output file.txt, --output=file.txt, -o file.txt, -ofile.txt
  • Boolean flags: options that take no value (--verbose, -v)
  • Positional arguments: matched by position, with count validation
  • Default values: fallback when an argument is not provided
  • Required arguments: validation that mandatory arguments are present
  • Auto-generated help: --help / -h with formatted usage and descriptions
  • Version display: --version / -V
  • -- stop marker: everything after -- is treated as positional
  • Short flag merging: -abc expands to -a -b -c
  • Attached short values: -ofile.txt is equivalent to -o file.txt
  • Choices validation: restrict values to an allowed set (e.g., json, csv, table)
  • Metavar: custom display name for values in help text (e.g., --format <FMT>)
  • Hidden arguments: exclude internal arguments from --help output
  • Count flags: -vvv → get_count("verbose") == 3
  • Negatable flags: --color / --no-color paired flags with .negatable()
  • Mutually exclusive groups: prevent conflicting flags (e.g., --json vs --yaml)
  • Required-together groups: enforce related flags are provided together (e.g., --username + --password)
  • Long option prefix matching: allow abbreviated options (e.g., --verb → --verbose), with ambiguity detection
  • print_summary() method: human-readable summary of all parsed arguments

📚 Documentation and testing

  • Comprehensive user manual covering every feature
  • Unit tests covering all features and edge cases
  • Demo CLI application (demo.mojo) showcasing all features
  • CI workflow for Ubuntu and macOS

Contributors

@forfudan