mirror of
https://github.com/SinTan1729/movie-rename.git
synced 2024-12-25 19:58:36 -06:00
Exit gracefully if config file doesn't exist
This commit is contained in:
parent
7165812709
commit
6d94a5429f
2 changed files with 8 additions and 2 deletions
|
@ -21,12 +21,18 @@ fn main() {
|
|||
config_file.push_str("/.config");
|
||||
}
|
||||
config_file.push_str("/movie-rename/config");
|
||||
|
||||
if Path::new(config_file.as_str()).is_file() == false {
|
||||
eprintln!("Error reading the config file. Pass --help to see help.");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
let mut config = load_str!(config_file.as_str()).lines();
|
||||
let api_key = config.next().unwrap_or("");
|
||||
let pattern = config.next().unwrap_or("{title} ({year}) - {director}");
|
||||
|
||||
if api_key == "" {
|
||||
eprintln!("Error reading the config file. Pass --help to see help.");
|
||||
eprintln!("Could not read the API key. Pass --help to see help.");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ impl fmt::Display for MovieEntry {
|
|||
get_long_lang(self.language.as_str())
|
||||
));
|
||||
buffer.push_str(&format!("Directed by: {}, ", self.director));
|
||||
buffer.push_str(&format!("TMDb ID: {}", self.id));
|
||||
buffer.push_str(&format!("TMDB ID: {}", self.id));
|
||||
// buffer.push_str(&format!("Synopsis: {}", self.overview));
|
||||
write!(f, "{}", buffer)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue