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
-**`--` stop marker**: everything after `--` is treated as positional
28
29
-**Short flag merging**: `-abc` expands to `-a -b -c`
@@ -35,209 +36,159 @@ ArgMojo provides a builder-pattern API for defining and parsing command-line arg
35
36
-**Negatable flags**: `--color` / `--no-color` paired flags with `.negatable()`
36
37
-**Mutually exclusive groups**: prevent conflicting flags (e.g., `--json` vs `--yaml`)
37
38
-**Required-together groups**: enforce that related flags are provided together (e.g., `--username` + `--password`)
38
-
-**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`), an error is raised.
39
+
-**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.
40
+
-**Append / collect action**: `--tag x --tag y` collects repeated options into a list with `.append()`
41
+
-**One-required groups**: require at least one argument from a group (e.g., must provide `--json` or `--yaml`)
42
+
-**Value delimiter**: `--env dev,staging,prod` splits by delimiter into a list with `.delimiter(",")`
43
+
-**Multi-value options (nargs)**: `--point 10 20` consumes N consecutive values with `.nargs(N)`
39
44
40
45
---
41
46
42
-
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 [DeciMojo](https://github.com/forfudan/decimojo). 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.
47
+
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.
43
48
44
49
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.
45
50
46
51
## Installation
47
52
48
-
ArgMojo requires Mojo == 0.26.1 and uses [pixi](https://pixi.sh) for environment management.
53
+
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:
I make the Mojo version strictly 0.26.1 because that's the version I developed and tested on, and Mojo is rapidly evolving. Based on my experience, the library will not work every time there's a new Mojo release.
59
+
Then, you can install ArgMojo using any of these methods:
60
+
61
+
1. From the `pixi` CLI, run the command `pixi add argmojo`. This fetches the latest version and makes it immediately available for import.
62
+
63
+
1. In the `mojoproject.toml` file of your project, add the following dependency:
64
+
65
+
```toml
66
+
argmojo = "==0.2.0"
67
+
```
68
+
69
+
Then run `pixi install` to download and install the package.
70
+
71
+
The following table summarizes the package versions and their corresponding Mojo versions:
72
+
73
+
| `argmojo` version | `mojo` version | package manager |
0 commit comments