Skip to content

Commit

Permalink
move is_git_installed in cli_utils.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
o2sh committed Nov 11, 2020
1 parent 1fecaea commit 96e3a55
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 2 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@

use onefetch::{cli::Cli, cli_utils, error::*, info, repo};

use {
process::{Command, Stdio},
std::{io, process},
};
use std::{io, process};

mod onefetch;

fn run() -> Result<()> {
#[cfg(windows)]
let _ = ansi_term::enable_ansi_support();

if !is_git_installed() {
if !cli_utils::is_git_installed() {
return Err("git failed to execute!".into());
}

Expand Down Expand Up @@ -55,7 +52,3 @@ fn main() {
}
}
}

fn is_git_installed() -> bool {
Command::new("git").arg("--version").stdout(Stdio::null()).status().is_ok()
}
6 changes: 5 additions & 1 deletion src/onefetch/cli_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::onefetch::{
use colored::Color;
use std::env;
use std::io::Write;
use std::process::Command;
use std::process::{Command, Stdio};
use strum::IntoEnumIterator;

pub struct Printer<W> {
Expand Down Expand Up @@ -112,3 +112,7 @@ pub fn get_git_version() -> Result<String> {
let version = Command::new("git").arg("--version").output()?;
Ok(String::from_utf8_lossy(&version.stdout).replace('\n', ""))
}

pub fn is_git_installed() -> bool {
Command::new("git").arg("--version").stdout(Stdio::null()).status().is_ok()
}

0 comments on commit 96e3a55

Please sign in to comment.