From 96bbc250f58e5c0a35b36b652c25a0d907a32c2f Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Wed, 28 Apr 2021 01:07:53 +0530 Subject: [PATCH] Disallow zero parameters for zoxide add --- CHANGELOG.md | 5 +++++ src/cmd/add.rs | 15 +++++---------- src/cmd/mod.rs | 1 + templates/elvish.txt | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64b79aa..e04d523 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Manpages for each subcommand. - Default prompt for Nushell. +### Changed + +- `zoxide remove -i` now accepts multiple selections. +- `zoxide add` no longer accepts zero parameters. + ### Fixed - `cd -` on fish shells. diff --git a/src/cmd/add.rs b/src/cmd/add.rs index d6e5732..1b34cc3 100644 --- a/src/cmd/add.rs +++ b/src/cmd/add.rs @@ -11,20 +11,15 @@ use std::path::PathBuf; /// Add a new directory or increment its rank #[derive(Clap, Debug)] pub struct Add { - path: Option, + path: PathBuf, } impl Cmd for Add { fn run(&self) -> Result<()> { - let path = match &self.path { - Some(path) => { - if config::zo_resolve_symlinks() { - util::canonicalize(path) - } else { - util::resolve_path(path) - } - } - None => util::current_dir(), + let path = if config::zo_resolve_symlinks() { + util::canonicalize(&self.path) + } else { + util::resolve_path(&self.path) }?; if config::zo_exclude_dirs()? diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index b23e200..3b24f73 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -30,6 +30,7 @@ pub trait Cmd { about, author, after_help = ENV_HELP, + global_setting(AppSettings::ColoredHelp), global_setting(AppSettings::DisableHelpSubcommand), global_setting(AppSettings::GlobalVersion), global_setting(AppSettings::VersionlessSubcommands), diff --git a/templates/elvish.txt b/templates/elvish.txt index 68d2593..7db8174 100644 --- a/templates/elvish.txt +++ b/templates/elvish.txt @@ -32,9 +32,9 @@ if (not (and (builtin:has-env __zoxide_hooked) (builtin:eq (builtin:get-env __zo {%- when Hook::None %} {{ not_configured }} {%- when Hook::Prompt %} - edit:before-readline = [$@edit:before-readline []{ zoxide add $pwd }] + edit:before-readline = [$@edit:before-readline []{ zoxide add -- $pwd }] {%- when Hook::Pwd %} - after-chdir = [$@after-chdir [_]{ zoxide add $pwd }] + after-chdir = [$@after-chdir [_]{ zoxide add -- $pwd }] {%- endmatch %} }