Skip to content

Commit

Permalink
NO_COLOR support
Browse files Browse the repository at this point in the history
  • Loading branch information
xvxx committed Nov 17, 2020
1 parent 0db0c7e commit 2e78294
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
## v0.1.13-dev
## v0.1.14-dev

- If the `NO_COLOR` env variable is set, colors won't be printed to
the log. Same as starting with `--no-color`.
See https://no-color.org/.

## v0.1.13

- Added `--no-color` command line option to not display color when
logging.
- Slight change to binding behavior: if `-p` is passed without `-b`,
we'll try to bind to that port. To this easier: `phd -p 7777`
we'll try to bind to that port. To this easier: `phd -p 7777`
- Accept `?` as query string indicator, not just `TAB`. See #3.

## v0.1.12
Expand All @@ -29,7 +34,6 @@ For now you can view it by cloning the repository and running:

Enjoy!


## v0.1.10

`phd` can now render a single page to stdout, instead of starting
Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fn main() {
let mut host = DEFAULT_HOST;
let mut port = DEFAULT_PORT;
let mut render = "";

while let Some(arg) = args.next() {
match arg.as_ref() {
"--version" | "-v" | "-version" => return print_version(),
Expand Down Expand Up @@ -64,6 +65,11 @@ fn main() {
}
}

// https://no-color.org/
if std::env::var("NO_COLOR").is_ok() {
phd::color::hide_colors()
}

// If port was given and socket wasn't, bind to that port.
let bind = if port != DEFAULT_PORT && addr == DEFAULT_BIND {
format!("[::]:{}", port).parse().unwrap()
Expand Down

0 comments on commit 2e78294

Please sign in to comment.