Skip to content

Commit

Permalink
Rename util function for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
simeg committed Nov 13, 2018
1 parent e7791fe commit 270d476
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/file_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ impl ConfigManagement for FileHandler {
}

fn config_write(&self, config: Config, value: String) -> io::Result<()> {
let path = path::Path::new(&config_path_for(config));
let config_path = &config_path_for(config);
let path = path::Path::new(config_path);

let mut file = match fs::File::create(&path) {
Err(e) => panic!("Couldn't create {}: {}", path.display(), e.description()),
Expand Down Expand Up @@ -181,7 +182,7 @@ mod tests {
}

#[test]
fn file_system_create_dir_is_ok() {
fn tests_work() {
assert!(true, true);
}
}
2 changes: 1 addition & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub mod git {
}

fn git() -> String {
if utils::is_program_in_path("git") {
if utils::is_available("git") {
String::from("git")
} else {
panic!("Cannot locate executable - git - on your system")
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ fn open_pager_less(repo_config_file: String) -> Result<(), Error> {
}

fn less() -> String {
if utils::utils::is_program_in_path("less") {
if utils::utils::is_available("less") {
String::from("less")
} else {
panic!("Cannot locate executable - less - on your system")
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod utils {
use std::env;
use std::fs;

pub fn is_program_in_path(program: &str) -> bool {
pub fn is_available(program: &str) -> bool {
if let Ok(path) = env::var("PATH") {
for p in path.split(":") {
let p_str = format!("{}/{}", p, program);
Expand Down

0 comments on commit 270d476

Please sign in to comment.