10 releases

0.4.2 Jun 3, 2021
0.4.0 Jan 3, 2021
0.3.4 Aug 9, 2020
0.3.3 Jun 26, 2020
0.2.0 Jul 26, 2019

#19 in Command-line interface

Download history 19904/week @ 2021-05-30 23214/week @ 2021-06-06 24339/week @ 2021-06-13 24455/week @ 2021-06-20 23760/week @ 2021-06-27 23493/week @ 2021-07-04 23812/week @ 2021-07-11 22393/week @ 2021-07-18 22691/week @ 2021-07-25 25288/week @ 2021-08-01 25611/week @ 2021-08-08 51147/week @ 2021-08-15 36338/week @ 2021-08-22 36849/week @ 2021-08-29 33327/week @ 2021-09-05 41846/week @ 2021-09-12

78,588 downloads per month
Used in 247 crates (65 directly)

MIT license

31KB
666 lines

pico-args

Build Status Crates.io Documentation Rust 1.32+

An ultra simple CLI arguments parser.

If you think that this library doesn't support some feature, it's probably intentional.

  • No help generation.
  • Only flags, options, free arguments and subcommands are supported.
  • Options can be separated by a space, = or nothing. See build features.
  • Arguments can be in any order.
  • Non UTF-8 arguments are supported.

Build features

  • eq-separator

    Allows parsing arguments separated by =. Enabled by default.
    This feature adds about 1KiB to the resulting binary.

  • short-space-opt

    Makes the space between short keys and their values optional (e.g. -w10).
    If eq-separator is enabled, then it takes precedence and the '=' is not included.
    If eq-separator is disabled, then -K=value gives an error instead of returning "=value".
    The optional space is only applicable for short keys because --keyvalue would be ambiguous.

  • combined-flags

    Allows combination of flags, e.g. -abc instead of -a -b -c. If short-space-opt or eq-separator are enabled, you must parse flags after values, to prevent ambiguities.

Alternatives

The core idea of pico-args is to provide some "sugar" for arguments parsing without a lot of overhead (binary or compilation time wise). There are no point in comparing parsing features since pico-args supports only the bare minimum. So we will compare only the size overhead and compilation time.

There are a lot of arguments parsing implementations, but we will use only these one:

  • clap - is the most popular and complete one
  • gumdrop - a simple parser that uses procedural macros
  • structopt - a two above combined
  • argh - similar to gumdrop
null pico-args clap gumdrop structopt argh
Binary overhead 0KiB 14.3KiB 373.0KiB 19.8KiB 371.4KiB 17.6KiB
Build time 0.4s 0.7s 5.6s 4.1s 6.2s 4.0s
Number of dependencies 0 0 8 5 20 8
Tested version - 0.4.0 2.33.3 0.8.0 0.3.21 0.1.4
  • Binary size overhead was measured by subtracting the .text section size of an app with arguments parsing and a hello world app.
  • Build time was measured using hyperfine 'cargo clean; cargo build --release'.
  • Test projects can be found in test-apps/.

License

MIT

No runtime deps

Features

  • combined-flags
  • eq-separator
  • short-space-opt