Git Product home page Git Product logo

pico-args's Introduction

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.
  • No combined flags (like -vvv or -abc).
  • 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.

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

pico-args's People

Contributors

razrfalcon avatar matklad avatar hdamron17 avatar kjeremy avatar jyn514 avatar slyshyko avatar sigmasd avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.