Releases: milchinskiy/rust-args-parser
v2.0.0
What's Changed
- Infallible by default:
CmdSpec::handler,CmdSpec::validator,OptSpec::{flag,value},PosSpec::newcallbacks now return(). - Fallible variants: use
*_try(handler_try,validator_try,flag_try,value_try,new_try) when your callback needs to fail with a user-defined error:Result<(), E>whereE: std::error::Error + Send + Sync + 'static
- Validators:
validator(...)acceptsResult<(), E>whereE: std::fmt::Displayand maps failures toError::User(String).validator_try(...)acceptsResult<(), E>whereE: std::error::Error + Send + Sync + 'staticand maps failures toError::UserAny(...).
parse(...)still returnsResult<Matches, rust_args_parser::Error>. Parse errors are unchanged; user failures surface asError::User(...)/Error::UserAny(...).
- Next 2.0.0 by @milchinskiy in #2
Full Changelog: v1.0.1...v2.0.0
v1.0.1
Added
- Exposed counting-flag occurrences via
Matches::flag_count()andMatchView::flag_count(). This enables common patterns like-vvv/ repeated--verboseto be read directly from parsed matches, returning0when the flag is absent.
Full Changelog: v1.0.0...v1.0.1
v1.0.0
-
New entrypoint:
dispatch(...) -> Result<()>replaced byparse(&Env, &CmdSpec, &[OsString], &mut Ctx) -> Result<Matches>. -
Return type: parsing now returns a
Matchestree; usem.view()for leaf scope orm.at(&[])for root scope. -
Errors:
Error::Exit(code)replaced byError::ExitMsg { code, message }(e.g., for--help,--version). -
Env config: builder-style
Env::new(...).auto_help(...).auto_color()removed. Use the plain struct fields:Env { wrap_cols, color, suggest, auto_help, version, author }
-
Options API: unified constructors
- flags:
OptSpec::flag("name", fn(&mut Ctx)->Result<()>) - values:
OptSpec::value("name", fn(&OsStr, &mut Ctx)->Result<()>)
With builders:.short() .long() .metavar() .help() .env() .default() .group() .repeat() .validator()
- flags:
-
Positionals API: use
.required(),.many(), or.range(min, max)(replaces older.one()/legacy variants). -
Args type:
&[&str]→&[OsString](non-UTF-8 safe).
✨ Added
- Scoped matches API:
Matches+MatchViewfor ergonomic, scoped inspection. - Provenance:
is_set_from(name, Source::{Cli,Env,Default})to assert where a value came from (per-scope). - Flag occurrences: short clusters like
-vvvnow trigger the flag callback once per occurrence. - Validators everywhere: option/positional validators run for CLI, ENV and Default values; callbacks don’t fire on validation failure.
- Groups:
GroupMode::{Xor, ReqOne}enforced after overlays, across all sources. - Numeric look-ahead: tokens like
-1,-.5,+3.14,1e3,-1.2e-3are treated as values (not options). - End-of-options marker:
--reliably forces remaining tokens to be positional (even if they look like options).
🔧 Changed
- Overlay precedence clarified: CLI > ENV > Default; this order is now consistently validated and test-covered.
- Built-ins: help/version paths return
ExitMsg { code: 0, message }for friendly printing. - Defaults: feature set
default = ["help", "suggest", "color"](disable withdefault-features = false).
🐛 Fixed
- Optional positional greediness after
--no longer swallows the first token that looks like an option. - Leading
+in numeric tokens recognized byutil::looks_like_number_token.
Details in changelog
v0.4.3
fix(parser): apply env/defaults for ancestor commands before subcommand descent
Full Changelog: v0.4.2...v0.4.3
v0.4.2
fix(parser): allow root options before subcommand
Full Changelog: v0.4.1...v0.4.2
v0.4.1
- Help: Usage line ordering now also counts built-in options (help everywhere; version/author on root) when deciding whether to show
[options]. - help everywhere; version/author on root
Full Changelog: v0.4.0...v0.4.1
v0.4.0
- [breaking]
print_help_to(env, cmd, out)→print_help_to(env, cmd, path, out)where path is thesubcommandchain (no flags/positionals). This makesUsage:accurately reflect the full command path and preserves aliases. - [behavior] Invoking a command without a handler (non‑terminal) now prints help when
auto_helpis on and returnsExit(1);withauto_helpoff it returnsExit(1)without printing. - [tests] Added coverage for full‑path help and non‑terminal invocation.
Full Changelog: v0.3.0...v0.4.0
v0.3.0
- Breaking:
UnknownOption/UnknownCommandnow carry{ token, suggestions }. - Feature: Context‑aware typo hints for unknown options and commands.
- Docs: Updated error examples and migration guidance.
Full Changelog: v0.2.0...v0.3.0
v0.2.0
Full Changelog: v0.1.1...v0.2.0
v0.1.1
Full Changelog: v0.1.0...v0.1.1