diff options
author | Kyohei Uto <im@kyoheiu.dev> | 2024-01-14 05:15:22 +0900 |
---|---|---|
committer | Kyohei Uto <im@kyoheiu.dev> | 2024-01-14 05:15:22 +0900 |
commit | 55d69b525be94e0712c8e761e7ee9bd980ff2e33 (patch) | |
tree | fca80a7382035f9096fdd1b2d195a845d21f74cc | |
parent | c65961c29e2f59c2cbfa0671cf431e7bd226f18a (diff) |
Create the target file if not exists and quit after selection
-rw-r--r-- | src/main.rs | 4 | ||||
-rw-r--r-- | src/run.rs | 6 |
2 files changed, 3 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index 3a33a62..699da68 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,9 +49,7 @@ fn main() -> Result<(), errors::FxError> { _ => { if args[1].starts_with("--choosefiles=") { let target_path = PathBuf::from(args[1].split('=').nth(1).unwrap()); - if !target_path.exists() { - eprintln!("Target path does not exists."); - } else if let Err(e) = run::run( + if let Err(e) = run::run( std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")), false, Some(target_path), @@ -491,6 +491,7 @@ fn _run(mut state: State, session_path: PathBuf) -> Result<(), FxError> { if let Some(target_path) = &state.choosefiles_target { match std::fs::File::options() .append(true) + .create_new(true) .open(target_path) { Err(e) => print_warning(e, state.layout.y), @@ -502,10 +503,7 @@ fn _run(mut state: State, session_path: PathBuf) -> Result<(), FxError> { ) { print_warning(e, state.layout.y); } else { - print_info( - "Path written to the file.", - state.layout.y, - ); + break 'main; } } } |