diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 43726e8..d74551f 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -457,7 +457,15 @@ try handler.prepareOptions(common_args); catch (Exception e) { + if (options.noColors && options.forceColors) { + logError("Incompatible options: --no-colors and --force-colors"); + logInfo("Run 'dub help' for usage information."); + } + + // based on --no-colors or --force-colors we override whether initLogging() + // enabled colors or not in the first place if (options.noColors) setLoggingColorsEnabled(false); + if (options.forceColors) setLoggingColorsEnabled(true); logError("Error processing arguments: %s", e.msg); logDiagnostic("Full exception: %s", e.toString().sanitize); logInfo("Run 'dub help' for usage information."); @@ -538,7 +546,7 @@ */ struct CommonOptions { bool verbose, vverbose, quiet, vquiet, verror, version_; - bool help, annotate, bare, noColors; + bool help, annotate, bare, noColors, forceColors; string[] registry_urls; string root_path; SkipPackageSuppliers skipRegistry = SkipPackageSuppliers.none; @@ -569,6 +577,7 @@ args.getopt("verror", &verror, ["Only print errors"]); args.getopt("vquiet", &vquiet, ["Print no messages"]); args.getopt("no-colors", &noColors, ["Disable color output"]); + args.getopt("force-colors", &forceColors, ["Force output to be always colored"]); args.getopt("cache", &placementLocation, ["Puts any fetched packages in the specified location [local|system|user]."]); version_ = args.hasAppVersion;