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

Commit

Permalink
Add --no-colour flag (closes #53)
Browse files Browse the repository at this point in the history
All commands can now have their ANSI terminal formatting switched
off by adding the `--no-colour` switch.
  • Loading branch information
ninjabear committed Sep 30, 2016
1 parent f5bf708 commit dddb2a0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use std::process::Command;
use std::fs::File;
use std::io::Write;
use std::fs::OpenOptions;
use std::env;

mod factotum;

Expand All @@ -50,11 +51,11 @@ const USAGE: &'static str = "
Factotum.
Usage:
factotum run <factfile> [--start=<start_task>] [--env=<env>] [--dry-run]
factotum validate <factfile>
factotum dot <factfile> [--start=<start_task>] [--output=<output_file>] [--overwrite]
factotum (-h | --help)
factotum (-v | --version)
factotum run <factfile> [--start=<start_task>] [--env=<env>] [--dry-run] [--no-colour]
factotum validate <factfile> [--no-colour]
factotum dot <factfile> [--start=<start_task>] [--output=<output_file>] [--overwrite] [--no-colour]
factotum (-h | --help) [--no-colour]
factotum (-v | --version) [--no-colour]
Options:
-h --help Show this screen.
Expand All @@ -64,6 +65,7 @@ Options:
--dry-run Pretend to execute a Factfile, showing the commands that would be executed. Can be used with other options.
--output=<output_file> File to print output to. Used with `dot`.
--overwrite Overwrite the output file if it exists.
--no-colour Turn off ANSI terminal colours/formatting in output.
";

#[derive(Debug, RustcDecodable)]
Expand All @@ -73,6 +75,7 @@ struct Args {
flag_output: Option<String>,
flag_overwrite: bool,
flag_dry_run: bool,
flag_no_colour: bool,
arg_factfile: String,
flag_version: bool,
cmd_run: bool,
Expand Down Expand Up @@ -412,6 +415,10 @@ fn factotum() -> i32 {
return PROC_OTHER_ERROR
}
};

if args.flag_no_colour {
env::set_var("CLICOLOR", "0");
}

if args.flag_version {
println!("Factotum version {}", VERSION);
Expand Down

0 comments on commit dddb2a0

Please sign in to comment.