navigate can now handle path with spaces, path can only be last

argument though
This commit is contained in:
2025-03-30 13:20:29 +02:00
parent 3f05706dfb
commit 315ace51ed
2 changed files with 9 additions and 7 deletions
+4 -2
View File
@@ -42,7 +42,8 @@ pub struct PushArgs {
pub show_stack: Option<bool>, pub show_stack: Option<bool>,
/// change to <path> /// change to <path>
pub path: Option<String>, #[arg(num_args = 0..)]
pub path: Option<Vec<String>>,
} }
#[derive(Debug, Clone, Args)] #[derive(Debug, Clone, Args)]
@@ -113,7 +114,8 @@ pub struct BookmarkSubArgs {
pub name: String, pub name: String,
/// path of bookmark to add /// path of bookmark to add
pub path: Option<PathBuf>, #[arg(num_args = 0..)]
pub path: Vec<String>,
} }
#[derive(Debug, Clone, Args)] #[derive(Debug, Clone, Args)]
+5 -5
View File
@@ -88,7 +88,7 @@ fn handle_push(args: &PushArgs, config: &Config, stack: &mut Stack, output: &mut
const PREFIX: char = '='; const PREFIX: char = '=';
let mut path_string = match args.path.clone() { let mut path_string = match args.path.clone() {
Some(value) => value, Some(value) => value.join(" "),
None => { None => {
String::new() String::new()
} }
@@ -191,9 +191,9 @@ fn list_bookmarks(config: &Config, bookmarks: &mut Bookmarks, output: &mut Outpu
} }
fn add_bookmarks(args: &BookmarkSubArgs, config: &Config, bookmarks: &mut Bookmarks, output: &mut Output) -> Result<()> { fn add_bookmarks(args: &BookmarkSubArgs, config: &Config, bookmarks: &mut Bookmarks, output: &mut Output) -> Result<()> {
let mut path = match args.path.clone() { let mut path : PathBuf = match PathBuf::from_str(&args.path.join(" ")) {
Some(value) => value, Ok(value) => value,
None => return Err(Error::other("-- missing path argument")), Err(error) => return Err(Error::other(error.to_string())),
}; };
bookmarks.add_bookmark(&args.name, &path)?; bookmarks.add_bookmark(&args.name, &path)?;
@@ -230,7 +230,7 @@ fn push_path(path: &Path, stack: &mut Stack, _config: &Config, output: &mut Outp
return Err(Error::other("-- invalid path argument")); return Err(Error::other("-- invalid path argument"));
} else if !(path == current_path) { } else if !(path == current_path) {
stack.push_entry(&current_path)?; stack.push_entry(&current_path)?;
output.push_command(&format!("cd -- {}", match path.canonicalize()?.to_str() { output.push_command(&format!("cd -- '{}'", match path.canonicalize()?.to_str() {
Some(value) => value, Some(value) => value,
None => return Err(Error::other("-- failed to print provided path as string")), None => return Err(Error::other("-- failed to print provided path as string")),
})); }));