Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

v0.4.0

Latest
Compare
Choose a tag to compare
@killercup killercup released this 06 Dec 20:04
· 5 commits to master since this release

This release is only compatible with Rust 1.31.0 and later.

Added

  • The CliResult type alias was added as an easy to write type to be used as an
    return type in main functions. It uses the exitfailure crate internally.

Removed

  • The Result type alias has been removed from the prelude.

    To migrate from 0.3, please replace Result<$X> with Result<$X, Error>.

  • Structopt is no longer re-exported.

    To migrate from 0.3, please add structopt = "0.2" to your Cargo.toml,
    and add use structopt::StructOpt; to your source files.

  • The main! macro has been removed. It was the cause of much confusion and
    was originally introduced to work around the lack of support for using the ?
    operator in the main function.

    To migrate from 0.3, you should use a regular main function like
    fn main() -> CliResult { Ok(()) }. You'll need to return Ok(()) at the
    end to indicate the program was successful.

    To get access to your CLI arguments, use let args = Cli::from_args();
    (adjust the Cli name with the name of your struct that derives StructOpt.)

    To enable logging, it is easiest to add the line
    args.verbosity.setup_env_logger(&env!("CARGO_PKG_NAME"))?; right after the
    previous one loading the CLI arguments. You can also initialize a custom
    logger with the right log level directly by accessing
    args.verbosity.log_level().