Skip to content

Commit 8ae71ac

Browse files
committed
Disable color when not in tty
1 parent 105adf3 commit 8ae71ac

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ description = "A time tracking command-line utility"
44
repository = "https://github.com/chdsbd/doug"
55
documentation = "https://github.com/chdsbd/doug/blob/master/README.md"
66
license = "MIT"
7-
version = "1.2.3"
7+
version = "1.3.0"
88
authors = ["Christopher Dignam <chris@dignam.xyz>"]
99

1010
[dependencies]
11+
atty = "0.2.3"
1112
clap = "2.26.2"
1213
chrono = { version = "0.4", features = ["serde"] }
1314
serde = "1.0.15"

src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
extern crate atty;
12
extern crate chrono;
23
#[macro_use]
34
extern crate clap;
@@ -16,6 +17,7 @@ use std::path::{Path, PathBuf};
1617
use std::collections::HashMap;
1718
use std::process::Command;
1819

20+
use atty::Stream;
1921
use chrono::{Date, DateTime, Duration, Local, Utc};
2022
use clap::{App, AppSettings, Arg, SubCommand};
2123
use serde_json::Error;
@@ -98,6 +100,10 @@ fn main() {
98100

99101
let time_periods = periods();
100102

103+
if !atty::is(Stream::Stdout) {
104+
colored::control::set_override(false);
105+
}
106+
101107
if let Some(matches) = matches.subcommand_matches("start") {
102108
if matches.is_present("project") {
103109
start(

0 commit comments

Comments
 (0)