git integration
This commit is contained in:
26
src/git.rs
Normal file
26
src/git.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use crate::error;
|
||||
|
||||
use std::io;
|
||||
use std::str;
|
||||
use std::path;
|
||||
use std::process;
|
||||
use std::io::Write;
|
||||
|
||||
pub fn run_command(args : Vec<String>, vault_folder : &path::Path) -> Result<(), error::Error> {
|
||||
|
||||
let mut command = process::Command::new("git");
|
||||
|
||||
command
|
||||
.current_dir(vault_folder)
|
||||
// Force colour output even though run from other process.
|
||||
.args(["-c", "color.ui=always"])
|
||||
.args(args);
|
||||
|
||||
let output = command.output()?;
|
||||
let output_string = str::from_utf8(&output.stdout)?;
|
||||
|
||||
print!("{}", output_string);
|
||||
io::stdout().flush()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user