Add --force-colors option to force colors enabled
1 parent b7f60f5 commit a79c5768a705010824fa8f23ba1443a60986621c
@Giacomo De Lazzari Giacomo De Lazzari authored on 12 Jun 2018
Jan Jurzitza committed on 28 Jul 2022
Showing 1 changed file
View
11
source/dub/commandline.d
auto common_args = new CommandArgs(args[1..$]);
 
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.");
return 1;
/** Contains and parses options common to all commands.
*/
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;
PlacementLocation placementLocation = PlacementLocation.user;
args.getopt("q|quiet", &quiet, ["Only print warnings and errors"]);
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;
}