feature/error_handling #8
1 changed files with 8 additions and 1 deletions
|
@ -1,7 +1,14 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
fn error(message: &str) {
|
fn error(message: &str) {
|
||||||
eprintln!("{}: {}", env::args().next().unwrap(), message);
|
let argv0: String = env::args().next().unwrap();
|
||||||
|
let program_name = Path::new(&argv0)
|
||||||
|
.file_name()
|
||||||
|
.unwrap()
|
||||||
|
.to_str()
|
||||||
|
.unwrap();
|
||||||
|
eprintln!("{}: {}", program_name, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn command_not_found(command: &String) -> i32 {
|
pub fn command_not_found(command: &String) -> i32 {
|
||||||
|
|
Reference in a new issue