Gestion des erreurs : seul le nom du programme est affiché
This commit is contained in:
parent
62e34a9f46
commit
b0a89b688f
1 changed files with 8 additions and 1 deletions
|
@ -1,7 +1,14 @@
|
|||
use std::env;
|
||||
use std::path::Path;
|
||||
|
||||
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 {
|
||||
|
|
Reference in a new issue