Disable clap colors if no-color feature is used

This commit is contained in:
timvisee 2018-04-18 23:09:19 +02:00
parent 19657fbfaa
commit f1f0b20f5d
No known key found for this signature in database
GPG key ID: 109CBA0BF74036C2

View file

@ -29,7 +29,8 @@ pub struct Handler<'a> {
impl<'a: 'b, 'b> Handler<'a> {
/// Build the application CLI definition.
pub fn build() -> App<'a, 'b> {
App::new(crate_name!())
// Build the CLI application definition
let app = App::new(crate_name!())
.version(crate_version!())
.author(crate_authors!())
.about(crate_description!())
@ -59,7 +60,13 @@ impl<'a: 'b, 'b> Handler<'a> {
.subcommand(CmdInfo::build())
.subcommand(CmdParams::build())
.subcommand(CmdPassword::build())
.subcommand(CmdUpload::build().display_order(1))
.subcommand(CmdUpload::build().display_order(1));
// Disable color usage if compiled without color support
#[cfg(feature = "no-color")]
let app = app.global_setting(AppSettings::ColorNever);
app
}
/// Parse CLI arguments.