// not useful
//! Lightweight and flexible command line argument parser with derive and combinatoric style API
//! # Derive and combinatoric API
//!
//! `bpaf` supports both combinatoric and derive APIs and it's possible to mix and match both APIs
//! at once. Both APIs provide access to mostly the same features, some things are more convenient
//! to do with derive (usually less typing), some - with combinatoric (usually maximum flexibility
//! and reducing boilerplate structs). In most cases using just one would suffice. Whenever
//! possible APIs share the same keywords and overall structure. Documentation is shared and
//! contains examples for both combinatoric and derive style.
//!
//! `bpaf` supports dynamic shell completion for `bash`, `zsh`, `fish` and `elvish`.
//! # Quick links
//!
//! - [Derive tutorial](crate::_derive_tutorial)
//! - [Combinatoric tutorial](crate::_combinatoric_tutorial)
//! - [Some very unusual cases](crate::_unusual)
//! - [Applicative functors? What is it all about](crate::_applicative)
// - [Picking the right words](crate::_flow)
//! - [Batteries included](crate::batteries)
//! - [Q&A](https://github.com/pacak/bpaf/discussions/categories/q-a)
//! # Quick start - combinatoric and derive APIs
//!
//! <details>
//! <summary style="display: list-item;">Derive style API, click to expand</summary>
//!
//! 1. Add `bpaf` under `[dependencies]` in your `Cargo.toml`
//! ```toml
//! [dependencies]
//! bpaf = { version = "0.7", features = ["derive"] }
//! ```
//!
//! 2. Define a structure containing command line attributes and run generated function
//! ```no_run
//! use bpaf::Bpaf;
//!
//! #[derive(Clone, Debug, Bpaf)]
//! #[bpaf(options, version)]
//! /// Accept speed and distance, print them
//! struct SpeedAndDistance {
//! /// Speed in KPH
//! speed: f64,
//! /// Distance in miles
//! distance: f64,
//! }
//!
//! fn main() {
//! // #[derive(Bpaf)] generates `speed_and_distance` function
//! let opts = speed_and_distance().run();
//! println!("Options: {:?}", opts);
//! }
//! ```
//!
//! 3. Try to run the app
//! ```console
//! % very_basic --help
//! Accept speed and distance, print them
//!
//! Usage: --speed ARG --distance ARG
//!
//! Available options:
//! --speed <ARG> Speed in KPH
//! --distance <ARG> Distance in miles
//! -h, --help Prints help information
//! -V, --version Prints version information
//!
//! % very_basic --speed 100
//! Expected --distance ARG, pass --help for usage information
//!
//! % very_basic --speed 100 --distance 500
//! Options: SpeedAndDistance { speed: 100.0, distance: 500.0 }
//!
//! % very_basic --version
//! Version: 0.5.0 (taken from Cargo.toml by default)
//! ```
//! 4. You can check the [derive tutorial](crate::_derive_tutorial) for more detailed information.
//!
//! </details>
//!
//! <details>
//! <summary style="display: list-item;">Combinatoric style API, click to expand</summary>
//!
//! 1. Add `bpaf` under `[dependencies]` in your `Cargo.toml`
//! ```toml
//! [dependencies]
//! bpaf = "0.7"
//! ```
//!
//! 2. Declare parsers for components, combine them and run it
//! ```no_run
//! use bpaf::{construct, long, Parser};
//! #[derive(Clone, Debug)]
//! struct SpeedAndDistance {
//! /// Dpeed in KPH
//! speed: f64,
//! /// Distance in miles
//! distance: f64,
//! }
//!
//! fn main() {
//! // primitive parsers
//! let speed = long("speed")
//! .help("Speed in KPG")
//! .argument::<f64>("SPEED");
//!
//! let distance = long("distance")
//! .help("Distance in miles")
//! .argument::<f64>("DIST");
//!
//! // parser containing information about both speed and distance
//! let parser = construct!(SpeedAndDistance { speed, distance });
//!
//! // option parser with metainformation attached
//! let speed_and_distance
//! = parser
//! .to_options()
//! .descr("Accept speed and distance, print them");
//!
//! let opts = speed_and_distance.run();
//! println!("Options: {:?}", opts);
//! }
//! ```
//!
//! 3. Try to run the app
//!
//! ```console
//! % very_basic --help
//! Accept speed and distance, print them
//!
//! Usage: --speed ARG --distance ARG
//!
//! Available options:
//! --speed <ARG> Speed in KPH
//! --distance <ARG> Distance in miles
//! -h, --help Prints help information
//! -V, --version Prints version information
//!
//! % very_basic --speed 100
//! Expected --distance ARG, pass --help for usage information
//!
//! % very_basic --speed 100 --distance 500
//! Options: SpeedAndDistance { speed: 100.0, distance: 500.0 }
//!
//! % very_basic --version
//! Version: 0.5.0 (taken from Cargo.toml by default)
//! ```
//!
//! 4. You can check the [combinatoric tutorial](crate::_combinatoric_tutorial) for more detailed information.
//!
//!
//! </details>
//!
//! # Design goals: flexibility, reusability, correctness
//!
//! Library allows to consume command line arguments by building up parsers for individual
//! arguments and combining those primitive parsers using mostly regular Rust code plus one macro.
//! For example it's possible to take a parser that requires a single floating point number and
//! transform it to a parser that takes several of them or takes it optionally so different
//! subcommands or binaries can share a lot of the code:
//!
//! ```rust
//! # use bpaf::*;
//! // a regular function that doesn't depend on any context, you can export it
//! // and share across subcommands and binaries
//! fn speed() -> impl Parser<f64> {
//! long("speed")
//! .help("Speed in KPH")
//! .argument::<f64>("SPEED")
//! }
//!
//! // this parser accepts multiple `--speed` flags from a command line when used,
//! // collecting results into a vector
//! fn multiple_args() -> impl Parser<Vec<f64>> {
//! speed().many()
//! }
//!
//! // this parser checks if `--speed` is present and uses value of 42.0 if it's not
//! fn with_fallback() -> impl Parser<f64> {
//! speed().fallback(42.0)
//! }
//! ```
//!
//! At any point you can apply additional validation or fallback values in terms of current parsed
//! state of each subparser and you can have several stages as well:
//!
//! ```rust
//! # use bpaf::*;
//! #[derive(Clone, Debug)]
//! struct Speed(f64);
//! fn speed() -> impl Parser<Speed> {
//! long("speed")
//! .help("Speed in KPH")
//! .argument::<f64>("SPEED")
//!
//! // You can perform additional validation with `parse` and `guard` functions
//! // in as many steps as required.
//! // Before and after next two applications the type is still `impl Parser<f64>`
//! .guard(|&speed| speed >= 0.0, "You need to buy a DLC to move backwards")
//! .guard(|&speed| speed <= 100.0, "You need to buy a DLC to break the speed limits")
//!
//! // You can transform contained values, next line gives `impl Parser<Speed>` as a result
//! .map(|speed| Speed(speed))
//! }
//! ```
//!
//! Library follows **parse, don’t validate** approach to validation when possible. Usually you parse
//! your values just once and get the results as a Rust struct/enum with strict types rather than a
//! stringly typed hashmap with stringly typed values in both combinatoric and derive APIs.
//! # Design goals: restrictions
//!
//! The main restricting library sets is that you can't use parsed values (but not the fact that
//! parser succeeded or failed) to decide how to parse subsequent values. In other words parsers
//! don't have the monadic strength, only the applicative one - for more detailed explanation see
//! [Applicative functors? What is it all about](crate::_applicative).
//!
//!
//! To give an example, you can implement this description:
//!
//! > Program takes one of `--stdout` or `--file` flag to specify the output target, when it's `--file`
//! > program also requires `-f` attribute with the filename
//!
//! But not this one:
//!
//! > Program takes an `-o` attribute with possible values of `'stdout'` and `'file'`, when it's `'file'`
//! > program also requires `-f` attribute with the filename
//!
//! This set of restrictions allows `bpaf` to extract information about the structure of the computations
//! to generate help, dynamic completion and overall results in less confusing enduser experience
//!
//! `bpaf` performs no parameter names validation, in fact having multiple parameters
//! with the same name is fine and you can combine them as alternatives and performs no fallback
//! other than [`fallback`](Parser::fallback). You need to pay attention to the order of the
//! alternatives inside the macro: parser that consumes the left most available argument on a
//! command line wins, if this is the same - left most parser wins. So to parse a parameter
//! `--test` that can be both [`switch`](NamedArg::switch) and [`argument`](NamedArg::argument) you
//! should put the argument one first.
//!
//! You must place [`positional`] items at the end of a structure in derive API or consume them
//! as last arguments in derive API.
//! # Dynamic shell completion
//!
//! `bpaf` implements shell completion to allow to automatically fill in not only flag and command
//! names, but also argument and positional item values.
//!
//! 1. Enable `autocomplete` feature:
//! ```toml
//! bpaf = { version = "0.7", features = ["autocomplete"] }
//! ```
//! 2. Decorate [`argument`](NamedArg::argument) and [`positional`] parsers with
//! [`complete`](Parser::complete) to autocomplete argument values
//!
//! 3. Depending on your shell generate appropriate completion file and place it to whereever your
//! shell is going to look for it, name of the file should correspond in some way to name of
//! your program. Consult manual for your shell for the location and named conventions:
//! 1. **bash**: for the first `bpaf` completion you need to install the whole script
//! ```console
//! $ your_program --bpaf-complete-style-bash >> ~/.bash_completion
//! ```
//! but since the script doesn't depend on a program name - it's enough to do this for
//! each next program
//! ```console
//! echo "complete -F _bpaf_dynamic_completion your_program" >> ~/.bash_completion
//! ```
//! 2. **zsh**: note `_` at the beginning of the filename
//! ```console
//! $ your_program --bpaf-complete-style-zsh > ~/.zsh/_your_program
//! ```
//! 3. **fish**
//! ```console
//! $ your_program --bpaf-complete-style-fish > ~/.config/fish/completions/your_program.fish
//! ```
//! 4. **elvish** - not sure where to put it, documentation is a bit cryptic
//! ```console
//! $ your_program --bpaf-complete-style-elvish
//! ```
//! 4. Restart your shell - you need to done it only once or optionally after bpaf major version
//! upgrade: generated completion files contain only instructions how to ask your program for
//! possible completions and don't change even if options are different.
//!
//! 5. Generated scripts rely on your program being accessible in $PATH
//! # Design non goals: performance
//!
//! Library aims to optimize for flexibility, reusability and compilation time over runtime
//! performance which means it might perform some additional clones, allocations and other less
//! optimal things. In practice unless you are parsing tens of thousands of different parameters
//! and your app exits within microseconds - this won't affect you. That said - any actual
//! performance related problems with real world applications is a bug.
//! # More examples
//!
//! You can find a more examples here: <https://github.com/pacak/bpaf/tree/master/examples>
//!
//!
//! They're usually documented or at least contain an explanation to important bits and you can see
//! how they work by cloning the repo and running
//! ```shell
//! $ cargo run --example example_name
//! ```
//! # Testing your own parsers
//!
//! You can test your own parsers to maintain compatibility or simply checking expected output
//! with [`run_inner`](OptionParser::run_inner)
//!
//! ```rust
//! # use bpaf::*;
//! #[derive(Debug, Clone, Bpaf)]
//! #[bpaf(options)]
//! pub struct Options {
//! pub user: String
//! }
//!
//! #[test]
//! fn test_my_options() {
//! let help = options()
//! .run_inner(Args::from(&["--help"]))
//! .unwrap_err()
//! .unwrap_stdout();
//! let expected_help = "\
//! Usage --user <ARG>
//! <skip>
//! ";
//!
//! assert_eq!(help, expected_help);
//! }
//! ```
//!
//! # Cargo features
//!
//! - `derive`: adds a dependency on `bpaf_derive` crate and reexport `Bpaf` derive macro. You
//! need to enable it to use derive API. Disabled by default.
//!
//! - `extradocs`: used internally to include tutorials to <https://docs.rs/bpaf>, no reason to
//! enable it for local development unless you want to build your own copy of the documentation
//! (<https://github.com/rust-lang/cargo/issues/8905>). Disabled by default.
//!
//! - `batteries`: helpers implemented with public `bpaf` API. Disabled by default.
//!
//! - `autocomplete`: enables support for shell autocompletion. Disabled by default.
//!
//! - `bright-color`, `dull-color`: use more colors when printing `--help` and such. Enabling
//! either color feature adds some extra dependencies and might raise MRSV. If you are planning
//! to use this feature in a published app - it's best to expose them as feature flags:
//! ```toml
//! [features]
//! bright-color = ["bpaf/bright-color"]
//! dull-color = ["bpaf/dull-color"]
//! ```
//! Disabled by default.
//!
//! - `manpage`: generate man page from help declaration, see [`OptionParser::as_manpage`]. Disabled by default.
//!
//!
pub use set_override;
pub use set_override;
pub use crate Error;
use crate Item;
use PhantomData;
pub use ;
pub use crate ShellComp;
pub use Section;
use ;
use ;
pub use crate Args;
pub use crate FromUtf8;
pub use crate OptionParser;
pub use crate Meta;
pub use crate;
pub use crate NamedArg;
pub use Bpaf;
/// Compose several parsers to produce a single result
///
/// # Usage reference
/// ```rust
/// # use bpaf::*;
/// # { struct Res(bool, bool, bool);
/// # let a = short('a').switch(); let b = short('b').switch(); let c = short('c').switch();
/// // structs with unnamed fields:
/// construct!(Res(a, b, c));
/// # }
///
/// # { struct Res { a: bool, b: bool, c: bool }
/// # let a = short('a').switch(); let b = short('b').switch(); let c = short('c').switch();
/// // structs with named fields:
/// construct!(Res {a, b, c});
/// # }
///
/// # { enum Ty { Res(bool, bool, bool) }
/// # let a = short('a').switch(); let b = short('b').switch(); let c = short('c').switch();
/// // enums with unnamed fields:
/// construct!(Ty::Res(a, b, c));
/// # }
///
/// # { enum Ty { Res { a: bool, b: bool, c: bool } }
/// # let a = short('a').switch(); let b = short('b').switch(); let c = short('c').switch();
/// // enums with named fields:
/// construct!(Ty::Res {a, b, c});
/// # }
///
/// # { let a = short('a').switch(); let b = short('b').switch(); let c = short('c').switch();
/// // tuples:
/// construct!(a, b, c);
/// # }
///
/// # { let a = short('a').switch(); let b = short('b').switch(); let c = short('c').switch();
/// // parallel composition, tries all parsers, picks one that consumes the left most value,
/// // or if they consume the same (or not at all) - the left most in a list
/// construct!([a, b, c]);
/// # }
///
/// // defining primitive parsers inside construct macro :)
/// construct!(a(short('a').switch()), b(long("arg").argument::<usize>("ARG")));
///
/// # { let a = short('a').switch();
/// // defining a boxed parser
/// construct!(a);
/// # }
/// ```
///
/// # Combinatoric usage
/// `construct!` can compose parsers sequentially or in parallel.
///
/// Sequential composition runs each parser and if all of them succeed you get a parser object of a
/// new type back. Placeholder names for values inside `construct!` macro must correspond to both
/// struct/enum names and parser names present in scope. In examples below `a` corresponds to a
/// function and `b` corresponds to a variable name. Note parens in `a()`, you must to use them to
/// indicate function parsers.
///
/// Inside the parens you can put a whole expression to use instead of
/// having to define them in advance: `a(positional::<String>("POS"))`. Probably a good idea to use this
/// approach only for simple parsers.
///
/// ```rust
/// # use bpaf::*;
/// struct Res (u32, u32);
/// enum Ul { T { a: u32, b: u32 } }
///
/// // You can share parameters across multiple construct invocations
/// // if defined as functions
/// fn a() -> impl Parser<u32> {
/// short('a').argument::<u32>("N")
/// }
///
/// // You can construct structs or enums with unnamed fields
/// fn res() -> impl Parser<Res> {
/// let b = short('b').argument::<u32>("n");
/// construct!(Res ( a(), b ))
/// }
///
/// // You can construct structs or enums with named fields
/// fn ult() -> impl Parser<Ul> {
/// let b = short('b').argument::<u32>("n");
/// construct!(Ul::T { a(), b })
/// }
///
/// // You can also construct simple tuples
/// fn tuple() -> impl Parser<(u32, u32)> {
/// let b = short('b').argument::<u32>("n");
/// construct!(a(), b)
/// }
///
/// // You can create boxed version of parsers so the type matches as long
/// // as return type is the same - can be useful for all sort of dynamic parsers
/// fn boxed() -> impl Parser<u32> {
/// let a = short('a').argument::<u32>("n");
/// construct!(a)
/// }
///
/// // In addition to having primitives defined before using them - you can also define
/// // them directly inside construct macro. Probably only a good idea if you have only simple
/// // components
/// struct Options {
/// arg: u32,
/// switch: bool,
/// }
///
/// fn coyoda() -> impl Parser<Options> {
/// construct!(Options {
/// arg(short('a').argument::<u32>("ARG")),
/// switch(short('s').switch())
/// })
/// }
/// ```
///
/// Parallel composition picks one of several available parsers (result types must match) and returns a
/// parser object of the same type. Similar to sequential composition you can use parsers from variables
/// or functions:
///
/// ```rust
/// # use bpaf::*;
/// fn b() -> impl Parser<u32> {
/// short('b').argument::<u32>("NUM")
/// }
///
/// fn a_or_b() -> impl Parser<u32> {
/// let a = short('a').argument::<u32>("NUM");
/// // equivalent way of writing this would be `a.or_else(b())`
/// construct!([a, b()])
/// }
/// ```
///
/// # Derive usage
///
/// `bpaf_derive` would combine fields of struct or enum constructors sequentially and enum
/// variants in parallel.
/// ```rust
/// # use bpaf::*;
/// // to satisfy this parser user needs to pass both -a and -b
/// #[derive(Debug, Clone, Bpaf)]
/// struct Res {
/// a: u32,
/// b: u32,
/// }
///
/// // to satisfy this parser user needs to pass one (and only one) of -a, -b, -c or -d
/// #[derive(Debug, Clone, Bpaf)]
/// enum Enumeraton {
/// A { a: u32 },
/// B { b: u32 },
/// C { c: u32 },
/// D { d: u32 },
/// }
///
/// // here user needs to pass either both -a AND -b or both -c AND -d
/// #[derive(Debug, Clone, Bpaf)]
/// enum Ult {
/// AB { a: u32, b: u32 },
/// CD { c: u32, d: u32 }
/// }
/// ```
};
// construct!( a, b, c )
=> ;
// construct![a, b, c]
=> ;
=> ;
=> ;
=> ;
=> ;
=> ;
=> ;
=> ;
=> ;
}
/// to avoid extra parsing when autocomplete feature is off
/// for completion bpaf needs to observe all the failures in a branch
use FromStr;
/// Simple or composed argument parser
///
/// # Overview
///
/// It's best to think of an object implementing [`Parser`] trait as a container with a value
/// inside that are composable with other `Parser` containers using [`construct!`] and the only
/// way to extract this value is by transforming it to [`OptionParser`] with
/// [`to_options`](Parser::to_options) and running it with [`run`](OptionParser::run). At which
/// point you either get your value out or `bpaf` would generate a message describing a problem
/// (missing argument, validation failure, user requested help, etc) and the program would
/// exit.
///
/// Values inside can be of any type for as long as they implement `Debug`, `Clone` and
/// there's no lifetimes other than static.
///
/// When consuming the values you can jump straight to a value that implements
/// [`FromStr`] trait then transform into something that your program would actually use. Alternatively
/// you can consume either `String` or `OsString` and parse that by hand. It's better to perform
/// as much parsing and validation inside the `Parser` as possible so the program itself gets
/// strictly typed and correct value while user gets immediate feedback on what's wrong with the
/// arguments they pass.
///
/// For example suppose your program needs user to specify a dimensions of a rectangle, with sides
/// being 1..20 units long and the total area must not exceed 200 units square. A parser that
/// consumes it might look like this:
///
/// ```rust
/// # use bpaf::*;
/// #[derive(Debug, Copy, Clone)]
/// struct Rectangle {
/// width: u32,
/// height: u32,
/// }
///
/// fn rectangle() -> impl Parser<Rectangle> {
/// let invalid_size = "Sides of a rectangle must be 1..20 units long";
/// let invalid_area = "Area of a rectangle must not exceed 200 units square";
/// let width = long("width")
/// .help("Width of the rectangle")
/// .argument::<u32>("PX")
/// .guard(|&x| 1 <= x && x <= 10, invalid_size);
/// let height = long("height")
/// .help("Height of the rectangle")
/// .argument::<u32>("PX")
/// .guard(|&x| 1 <= x && x <= 10, invalid_size);
/// construct!(Rectangle { width, height })
/// .guard(|&r| r.width * r.height <= 400, invalid_area)
/// }
/// ```
///
///
/// # Derive specific considerations
///
/// Every method defined on this trait belongs to the `postprocessing` section of the field
/// annotation. `bpaf_derive` would try to figure out what chain to use for as long as there's no
/// options changing the type: you can use [`fallback`](Parser::fallback_with),
/// [`fallback_with`](Parser::fallback_with), [`guard`](Parser::guard), [`hide`](Parser::hide`) and
/// [`group_help`](Parser::group_help) but not the rest of them.
///
/// ```rust
/// # use bpaf::*;
/// #[derive(Debug, Clone, Bpaf)]
/// struct Options {
/// // no annotation at all - `bpaf_derive` inserts implicit `argument` and gets the right type
/// number_1: u32,
///
/// // fallback isn't changing the type so `bpaf_derive` still handles it
/// #[bpaf(fallback(42))]
/// number_2: u32,
///
/// // `bpaf_derive` inserts implicit `argument`, `optional` and the right type
/// number_3: Option<u32>,
///
/// // fails to compile: you need to specify `argument`
/// // #[bpaf(optional)]
/// // number_4: Option<u32>,
///
/// #[bpaf(argument("N"), optional)]
/// number_5: Option<u32>,
///
/// // explicit consumer and a full postprocessing chain
/// #[bpaf(argument::<u32>("N"), optional)]
/// number_6: Option<u32>,
/// }
/// ```
/// Various complete options decorations
///
/// Somewhat work in progress, only makes a difference in zsh
/// # Combinatoric usage
/// ```rust
/// # use bpaf::*;
/// fn pair() -> impl Parser<(bool, bool)> {
/// let a = short('a').switch();
/// let b = short('b').switch();
/// construct!(a, b)
/// .complete_style(CompleteDecor::VisibleGroup("a and b"))
/// }
/// ```
///
/// # Derive usage
/// ```rust
/// # use bpaf::*;
/// #[derive(Debug, Clone, Bpaf)]
/// #[bpaf(complete_style(CompleteDecor::VisibleGroup("a and b")))]
/// struct Options {
/// a: bool,
/// b: bool,
/// }
/// ```
///
/// Wrap a value into a `Parser`
///
/// This parser produces `T` without consuming anything from the command line, can be useful
/// with [`construct!`]. As with any parsers `T` should be `Clone` and `Debug`.
///
/// Both `pure` and [`pure_with`] are designed to put values into structures, to generate fallback
/// you should be using [`fallback`](Parser::fallback) and [`fallback_with`](Parser::fallback_with).
///
/// See also [`pure_with`] for a pure computation that can fail.
///
/// # Combinatoric usage
/// ```rust
/// # use bpaf::*;
/// fn pair() -> impl Parser<(bool, u32)> {
/// let a = long("flag-a").switch();
/// let b = pure(42u32);
/// construct!(a, b)
/// }
/// ```
/// Wrap a calculated value into a `Parser`
///
/// This parser represents a possibly failing equivalent to [`pure`].
/// It produces `T` by invoking the provided callback without consuming anything from the command
/// line, can be useful with [`construct!`]. As with any parsers `T` should be `Clone` and `Debug`.
///
/// Both [`pure`] and `pure_with` are designed to put values into structures, to generate fallback
/// you should be using [`fallback`](Parser::fallback) and [`fallback_with`](Parser::fallback_with).
///
/// See also [`pure`] for a pure computation that can't fail.
/// # Combinatoric usage
/// ```rust
/// # use bpaf::*;
/// fn pair() -> impl Parser<bool> {
/// let a = long("flag-a").switch();
/// let b = pure_with::<_, _, String>(|| {
/// // search for history file and try to fish out the last used value ...
/// // if this computation fails - user will see it
/// Ok(false)
/// });
/// construct!([a, b])
/// }
/// ```
/// Fail with a fixed error message
///
/// This parser produces `T` of any type but instead of producing it when asked - it fails
/// with a custom error message. Can be useful for creating custom logic
///
/// # Combinatoric usage
/// ```rust
/// # use bpaf::*;
/// fn must_agree() -> impl Parser<()> {
/// let a = long("accept").req_flag(());
/// let no_a = fail("You must accept the license agreement with --agree before proceeding");
/// construct!([a, no_a])
/// }
/// ```
///
/// # Example
/// ```console
/// $ app
/// // exits with "You must accept the license agreement with --agree before proceeding"
/// $ app --agree
/// // succeeds
/// ```
/// Unsuccessful command line parsing outcome, use it for unit tests
///
/// Useful for unit testing for user parsers, consume it with
/// [`ParseFailure::unwrap_stdout`] and [`ParseFailure::unwrap_stdout`]
/// Strip a command name if present at the front when used as a `cargo` command
///
/// See batteries::cargo_helper