From f1f0b20f5d84d5a706e5280acd66d4e03b2e408f Mon Sep 17 00:00:00 2001 From: timvisee Date: Wed, 18 Apr 2018 23:09:19 +0200 Subject: [PATCH] Disable clap colors if no-color feature is used --- cli/src/cmd/handler.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cli/src/cmd/handler.rs b/cli/src/cmd/handler.rs index b4f2914..8a3d950 100644 --- a/cli/src/cmd/handler.rs +++ b/cli/src/cmd/handler.rs @@ -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.