summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyohei Uto <im@kyoheiu.dev>2024-01-20 07:28:19 +0900
committerKyohei Uto <im@kyoheiu.dev>2024-01-20 07:28:19 +0900
commit67e13674f5aac693d617a879be2d7faa2f95c9c3 (patch)
tree57fd6cd001e7c025aeb3c15600bf17e398790b9a
parent572802f0957b154546b9b2c89f0b8de6f69b90cc (diff)
Error handling for target path
-rw-r--r--src/main.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index d3fd81b..aa76aff 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -48,13 +48,16 @@ fn main() -> Result<(), errors::FxError> {
}
_ => {
if args[1].starts_with("--choosefiles=") {
- let target_path = PathBuf::from(args[1].split('=').nth(1).unwrap());
- if let Err(e) = run::run(
- std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")),
- false,
- Some(target_path),
- ) {
- eprintln!("{}", e);
+ if let Some(target_path) = args[1].split('=').nth(1) {
+ if let Err(e) = run::run(
+ std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")),
+ false,
+ Some(PathBuf::from(target_path)),
+ ) {
+ eprintln!("{}", e);
+ }
+ } else {
+ eprintln!("Cannot read target file path.");
}
} else if let Err(e) = run::run(PathBuf::from(&args[1]), false, None) {
eprintln!("{}", e);