You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Positional arg count validation**: reject extra positional args
@@ -52,18 +52,46 @@ ArgMojo provides a builder-pattern API for defining and parsing command-line arg
52
52
-**Long option prefix matching**: allow abbreviated options (e.g., `--verb` → `--verbose`). If the prefix is ambiguous (e.g., `--ver` could match both `--verbose` and `--version-info`), an error is raised.
53
53
-**Append / collect action**: `--tag x --tag y` collects repeated options into a list with `.append()`
54
54
-**One-required groups**: require at least one argument from a group (e.g., must provide `--json` or `--yaml`)
55
-
-**Value delimiter**: `--env dev,staging,prod` splits by delimiter into a list with `.delimiter(",")`
56
-
-**Multi-value options (nargs)**: `--point 10 20` consumes N consecutive values with `.nargs(N)`
55
+
-**Value delimiter**: `--env dev,staging,prod` splits by delimiter into a list with `.delimiter[","]()`
56
+
-**Multi-value options (nargs)**: `--point 10 20` consumes N consecutive values with `.number_of_values[N]()`
-**Remainder positional**: `.remainder()` consumes all remaining tokens
80
+
-**Allow hyphen values**: `.allow_hyphen_values()` accepts `-` as a regular value (stdin convention)
81
+
-**Partial parsing**: `parse_known_arguments()` collects unrecognised options instead of erroring
82
+
-**Compile-time validation**: builder parameters validated at `mojo build` time via `comptime assert`
83
+
-**Registration-time validation**: group constraint typos caught when the program starts, not when the user runs it
58
84
59
85
---
60
86
61
87
I created this project to support my experiments with a CLI-based Chinese character search engine in Mojo, as well as a CLI-based calculator for [Decimo](https://github.com/forfudan/decimo). It is inspired by Python's `argparse`, Rust's `clap`, Go's `cobra`, and other popular argument parsing libraries, but designed to fit Mojo's unique features and constraints.
62
88
63
-
My goal is to provide a Mojo-idiomatic argument parsing library that can be easily adopted by the growing Mojo community for their CLI applications. **Before Mojo v1.0** (which means it gets stable), my focus is on building core features and ensuring correctness. "Core features" refer to those who appear in `argparse`/`clap`/`cobra` and are commonly used in CLI apps. "Correctness" means that the library should handle edge cases properly, provide clear error messages, and have good test coverage. Some fancy features will depend on my time and interest.
89
+
My goal is to provide a Mojo-idiomatic argument parsing library that can be easily adopted by the growing Mojo community for their CLI applications. **Before Mojo v1.0** (which means it is not yet stable), my focus is on building core features and ensuring correctness. "Core features" refer to those who appear in `argparse`/`clap`/`cobra` and are commonly used in CLI apps. "Correctness" means that the library should handle edge cases properly, provide clear error messages, and have good test coverage. Some fancy features will depend on my time and interest.
64
90
65
91
## Installation
66
92
93
+
### Package Manager
94
+
67
95
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:
68
96
69
97
```toml
@@ -77,17 +105,14 @@ Then, you can install ArgMojo using any of these methods:
77
105
1. In the `mojoproject.toml` file of your project, add the following dependency:
78
106
79
107
```toml
80
-
argmojo = "==0.3.0"
108
+
argmojo = "*"
81
109
```
82
110
83
111
Then run `pixi install` to download and install the package.
84
112
85
-
The following table summarizes the package versions and their corresponding Mojo versions:
113
+
### Using mojopkg
86
114
87
-
| `argmojo` version | `mojo` version | package manager |
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.
91
116
92
117
## Quick Start
93
118
@@ -97,40 +122,39 @@ Here is a simple example of how to use ArgMojo in a Mojo program. See `examples/
97
122
from argmojo import Argument, Command
98
123
99
124
100
-
fn main() raises:
125
+
def main() raises:
101
126
var app = Command("mgrep", "Search for PATTERN in each FILE.", version="1.0.0")
0 commit comments