Skip to content

Releases: milchinskiy/rust-args-parser

v2.0.0

14 Feb 23:26
5da1839

Choose a tag to compare

What's Changed

  • Infallible by default: CmdSpec::handler, CmdSpec::validator, OptSpec::{flag,value}, PosSpec::new callbacks 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> where E: std::error::Error + Send + Sync + 'static
  • Validators:
    • validator(...) accepts Result<(), E> where E: std::fmt::Display and maps failures to Error::User(String).
    • validator_try(...) accepts Result<(), E> where E: std::error::Error + Send + Sync + 'static and maps failures to Error::UserAny(...).
  • parse(...) still returns Result<Matches, rust_args_parser::Error>. Parse errors are unchanged; user failures surface as Error::User(...) / Error::UserAny(...).

Full Changelog: v1.0.1...v2.0.0

v1.0.1

27 Dec 14:03

Choose a tag to compare

Added

  • Exposed counting-flag occurrences via Matches::flag_count() and MatchView::flag_count(). This enables common patterns like -vvv / repeated --verbose to be read directly from parsed matches, returning 0 when the flag is absent.

Full Changelog: v1.0.0...v1.0.1

v1.0.0

15 Nov 16:40
4f53d63

Choose a tag to compare

  • New entrypoint: dispatch(...) -> Result<()> replaced by parse(&Env, &CmdSpec, &[OsString], &mut Ctx) -> Result<Matches>.

  • Return type: parsing now returns a Matches tree; use m.view() for leaf scope or m.at(&[]) for root scope.

  • Errors: Error::Exit(code) replaced by Error::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()
  • 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 + MatchView for 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 -vvv now 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-3 are 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 with default-features = false).

🐛 Fixed

  • Optional positional greediness after -- no longer swallows the first token that looks like an option.
  • Leading + in numeric tokens recognized by util::looks_like_number_token.

Details in changelog

v0.4.3

12 Nov 23:00

Choose a tag to compare

fix(parser): apply env/defaults for ancestor commands before subcommand descent

Full Changelog: v0.4.2...v0.4.3

v0.4.2

12 Nov 22:27

Choose a tag to compare

fix(parser): allow root options before subcommand

Full Changelog: v0.4.1...v0.4.2

v0.4.1

26 Oct 19:00

Choose a tag to compare

  • 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

12 Oct 23:29

Choose a tag to compare

  • [breaking] print_help_to(env, cmd, out)print_help_to(env, cmd, path, out) where path is the subcommand chain (no flags/positionals). This makes Usage: accurately reflect the full command path and preserves aliases.
  • [behavior] Invoking a command without a handler (non‑terminal) now prints help when auto_help is on and returns Exit(1); with auto_help off it returns Exit(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

12 Oct 12:32

Choose a tag to compare

  • Breaking: UnknownOption / UnknownCommand now 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

01 Oct 19:19

Choose a tag to compare

Full Changelog: v0.1.1...v0.2.0

v0.1.1

30 Sep 16:58

Choose a tag to compare

Full Changelog: v0.1.0...v0.1.1