Skip to content

Fix compilation error on linux #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ bytecount = "0.5.1"
clap = "2.33.0"
strum = "0.16.0"
strum_macros = "0.16.0"
ansi_term = "0.12"

[target.'cfg(windows)'.dependencies]
ansi_term = "0.12"
15 changes: 13 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ extern crate colored;
extern crate git2;
extern crate license;
extern crate tokei;
extern crate ansi_term;
#[macro_use]
extern crate clap;
extern crate strum;
#[macro_use]
extern crate strum_macros;

#[cfg(target = "windows")]
extern crate ansi_term;

use colored::Color;
use colored::*;
use git2::{Repository, Oid};
Expand Down Expand Up @@ -446,9 +448,18 @@ impl fmt::Display for Language {
}

fn main() -> Result<()> {
if cfg!(windows) && !ansi_term::enable_ansi_support().is_ok() {

#[cfg(target = "windows")]
let enabled = ansi_term::enable_ansi_support().is_ok();

#[cfg(not(target = "windows"))]
let enabled = true;

if !enabled {
colored::control::set_override(false);
}


if !is_git_installed() {
return Err(Error::GitNotInstalled);
}
Expand Down