diff options
author | Justin Wernick <justin@worthe-it.co.za> | 2023-03-20 16:57:44 +0200 |
---|---|---|
committer | Justin Wernick <justin@worthe-it.co.za> | 2023-03-20 16:57:44 +0200 |
commit | 2ab7df378d8cb40775ac0ecd2849fa9966386a2e (patch) | |
tree | fb4c5ef0785e121c082dae9f0eca1051d879319b /src | |
parent | 4aaca79ed12d327328f7650b737cb47e5ed83fa7 (diff) |
Use clap to parse paths
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 6 | ||||
-rw-r--r-- | src/parser.rs | 8 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index e02be3e..56cd729 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,8 +62,7 @@ fn run_command(user_input: String) -> Result<ControlFlow<(), ()>, ShackleError> command.arg("advertise-refs"); } - // TODO: This should definitely be part of the arg parsing! - command.arg(&upload_pack_args.directory.trim_matches('\'')); + command.arg(&upload_pack_args.directory); command.spawn()?.wait()?; } @@ -74,8 +73,7 @@ fn run_command(user_input: String) -> Result<ControlFlow<(), ()>, ShackleError> command.arg("--http-backend-info-refs"); } - // TODO: This should definitely be part of the arg parsing! - command.arg(&receive_pack_args.directory.trim_matches('\'')); + command.arg(&receive_pack_args.directory); command.spawn()?.wait()?; } diff --git a/src/parser.rs b/src/parser.rs index 9938924..6a6459b 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,5 +1,5 @@ use clap::{Parser, Subcommand}; -use std::str::FromStr; +use std::{path::PathBuf, str::FromStr}; use thiserror::Error; #[derive(Parser, Clone, Debug, PartialEq, Eq)] @@ -35,14 +35,14 @@ pub struct GitUploadPackArgs { pub stateless_rpc: bool, #[arg(long)] pub advertise_refs: bool, - pub directory: String, + pub directory: PathBuf, } #[derive(Parser, Clone, Debug, PartialEq, Eq)] pub struct GitReceivePackArgs { #[arg(long)] pub http_backend_info_refs: bool, - pub directory: String, + pub directory: PathBuf, } #[derive(Error, Debug)] @@ -98,7 +98,7 @@ mod test { timeout: None, stateless_rpc: true, advertise_refs: false, - directory: "foobar.git".to_owned(), + directory: PathBuf::from("foobar.git"), }) ); } |