error : valeur par défaut pour le nom du programme
This commit is contained in:
parent
85a8aa40b4
commit
701643848a
1 changed files with 3 additions and 1 deletions
|
@ -1,7 +1,9 @@
|
|||
use std::env;
|
||||
use std::fmt::{Display, Formatter, Result};
|
||||
use std::path::Path;
|
||||
|
||||
pub fn print_error(message: &str) {
|
||||
let name = std::env::args().next().unwrap();
|
||||
let name = env::args().next().unwrap_or(String::from("rash"));
|
||||
let name = Path::new(&name).file_name().unwrap().to_str().unwrap();
|
||||
|
||||
eprintln!("{}: {}", name, message);
|
||||
|
|
Loading…
Reference in a new issue