Replace --no-aliases with --no-cmd

This commit is contained in:
Ajeet D'Souza 2022-04-11 03:41:51 +05:30
parent a0242d7c9a
commit b71d33b5c1
20 changed files with 131 additions and 124 deletions

View File

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Manpages: moved to `man/man1/*.1`.
- Replace `--no-aliases` with `--no-cmd`.
### Fixed

86
Cargo.lock generated
View File

@ -131,9 +131,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "3.1.6"
version = "3.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8c93436c21e4698bacadf42917db28b23017027a4deccb35dbe47a7e7840123"
checksum = "71c47df61d9e16dc010b55dba1952a57d8c215dbb533fd13cdd13369aac73b1c"
dependencies = [
"atty",
"bitflags",
@ -157,9 +157,9 @@ dependencies = [
[[package]]
name = "clap_complete_fig"
version = "3.1.0"
version = "3.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c11f6f44afea4aee21bb57a5297879c88ac8dc97224fbbbe796edd60a098f0e"
checksum = "690eb5abb7a98df1a64a3028beaf95af7e0ceb13da3186e6d0a86161af76309e"
dependencies = [
"clap",
"clap_complete",
@ -167,9 +167,9 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "3.1.4"
version = "3.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da95d038ede1a964ce99f49cbe27a7fb538d1da595e4b4f70b8c8f338d17bf16"
checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1"
dependencies = [
"heck",
"proc-macro-error",
@ -180,9 +180,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.7"
version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6"
checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
dependencies = [
"cfg-if",
"lazy_static",
@ -205,9 +205,9 @@ dependencies = [
[[package]]
name = "dirs-sys"
version = "0.3.6"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780"
checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
dependencies = [
"libc",
"redox_users",
@ -249,9 +249,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "getrandom"
version = "0.2.5"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77"
checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
dependencies = [
"cfg-if",
"libc",
@ -318,9 +318,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "1.8.0"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee"
dependencies = [
"autocfg",
"hashbrown",
@ -352,15 +352,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.119"
version = "0.2.122"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259"
[[package]]
name = "log"
version = "0.4.14"
version = "0.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8"
dependencies = [
"cfg-if",
]
@ -417,13 +417,12 @@ dependencies = [
[[package]]
name = "nom"
version = "7.1.0"
version = "7.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
dependencies = [
"memchr",
"minimal-lexical",
"version_check",
]
[[package]]
@ -512,39 +511,40 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.36"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.15"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58"
dependencies = [
"proc-macro2",
]
[[package]]
name = "redox_syscall"
version = "0.2.11"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c"
checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42"
dependencies = [
"bitflags",
]
[[package]]
name = "redox_users"
version = "0.4.0"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [
"getrandom",
"redox_syscall",
"thiserror",
]
[[package]]
@ -623,9 +623,9 @@ dependencies = [
[[package]]
name = "semver"
version = "1.0.6"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d"
checksum = "d65bd28f48be7196d222d95b9243287f48d27aca604e08497513019ff0502cc4"
[[package]]
name = "serde"
@ -661,9 +661,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.86"
version = "1.0.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b"
checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d"
dependencies = [
"proc-macro2",
"quote",
@ -705,6 +705,26 @@ version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
[[package]]
name = "thiserror"
version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "thread_local"
version = "1.1.4"

View File

@ -294,8 +294,8 @@ zoxide import --from z path/to/db
When calling `zoxide init`, the following flags are available:
- `--cmd`
- Changes the prefix of predefined aliases (`z`, `zi`).
- `--cmd j` would change the aliases to (`j`, `ji`).
- Changes the prefix of the `z` and `zi` commands.
- `--cmd j` would change the commands to (`j`, `ji`).
- `--cmd cd` would replace the `cd` command (doesn't work on Nushell / POSIX shells).
- `--hook <HOOK>`
- Changes how often zoxide increments a directory's score:
@ -304,8 +304,8 @@ When calling `zoxide init`, the following flags are available:
| `none` | Never |
| `prompt` | At every shell prompt |
| `pwd` | Whenever the directory is changed |
- `--no-aliases`
- Don't define aliases (`z`, `zi`).
- `--no-cmd`
- Prevents zoxide from defining the `z` and `zi` commands.
- These functions will still be available in your shell as `__zoxide_z` and
`__zoxide_zi`, should you choose to redefine them.

View File

@ -50,9 +50,9 @@ _arguments "${_arguments_options[@]}" \
;;
(init)
_arguments "${_arguments_options[@]}" \
'--cmd=[Renames the '\''z'\'' command and corresponding aliases]:CMD: ' \
'--hook=[Chooses event upon which an entry is added to the database]:HOOK:(none prompt pwd)' \
'--no-aliases[Prevents zoxide from defining any commands]' \
'--cmd=[Changes the prefix of the `z` and `zi` commands]:CMD: ' \
'--hook=[Changes how often zoxide increments a directory'\''s score]:HOOK:(none prompt pwd)' \
'--no-cmd[Prevents zoxide from defining the `z` and `zi` commands]' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \

View File

@ -49,9 +49,9 @@ Register-ArgumentCompleter -Native -CommandName 'zoxide' -ScriptBlock {
break
}
'zoxide;init' {
[CompletionResult]::new('--cmd', 'cmd', [CompletionResultType]::ParameterName, 'Renames the ''z'' command and corresponding aliases')
[CompletionResult]::new('--hook', 'hook', [CompletionResultType]::ParameterName, 'Chooses event upon which an entry is added to the database')
[CompletionResult]::new('--no-aliases', 'no-aliases', [CompletionResultType]::ParameterName, 'Prevents zoxide from defining any commands')
[CompletionResult]::new('--cmd', 'cmd', [CompletionResultType]::ParameterName, 'Changes the prefix of the `z` and `zi` commands')
[CompletionResult]::new('--hook', 'hook', [CompletionResultType]::ParameterName, 'Changes how often zoxide increments a directory''s score')
[CompletionResult]::new('--no-cmd', 'no-cmd', [CompletionResultType]::ParameterName, 'Prevents zoxide from defining the `z` and `zi` commands')
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help information')
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help information')
[CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Print version information')

View File

@ -80,7 +80,7 @@ _zoxide() {
return 0
;;
zoxide__init)
opts="-h -V --no-aliases --cmd --hook --help --version bash elvish fish nushell posix powershell xonsh zsh"
opts="-h -V --no-cmd --cmd --hook --help --version bash elvish fish nushell posix powershell xonsh zsh"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0

View File

@ -43,9 +43,9 @@ set edit:completion:arg-completer[zoxide] = {|@words|
cand --version 'Print version information'
}
&'zoxide;init'= {
cand --cmd 'Renames the ''z'' command and corresponding aliases'
cand --hook 'Chooses event upon which an entry is added to the database'
cand --no-aliases 'Prevents zoxide from defining any commands'
cand --cmd 'Changes the prefix of the `z` and `zi` commands'
cand --hook 'Changes how often zoxide increments a directory''s score'
cand --no-cmd 'Prevents zoxide from defining the `z` and `zi` commands'
cand -h 'Print help information'
cand --help 'Print help information'
cand -V 'Print version information'

View File

@ -11,9 +11,9 @@ complete -c zoxide -n "__fish_seen_subcommand_from import" -l from -d 'Applicati
complete -c zoxide -n "__fish_seen_subcommand_from import" -l merge -d 'Merge into existing database'
complete -c zoxide -n "__fish_seen_subcommand_from import" -s h -l help -d 'Print help information'
complete -c zoxide -n "__fish_seen_subcommand_from import" -s V -l version -d 'Print version information'
complete -c zoxide -n "__fish_seen_subcommand_from init" -l cmd -d 'Renames the \'z\' command and corresponding aliases' -r
complete -c zoxide -n "__fish_seen_subcommand_from init" -l hook -d 'Chooses event upon which an entry is added to the database' -r -f -a "{none ,prompt ,pwd }"
complete -c zoxide -n "__fish_seen_subcommand_from init" -l no-aliases -d 'Prevents zoxide from defining any commands'
complete -c zoxide -n "__fish_seen_subcommand_from init" -l cmd -d 'Changes the prefix of the `z` and `zi` commands' -r
complete -c zoxide -n "__fish_seen_subcommand_from init" -l hook -d 'Changes how often zoxide increments a directory\'s score' -r -f -a "{none ,prompt ,pwd }"
complete -c zoxide -n "__fish_seen_subcommand_from init" -l no-cmd -d 'Prevents zoxide from defining the `z` and `zi` commands'
complete -c zoxide -n "__fish_seen_subcommand_from init" -s h -l help -d 'Print help information'
complete -c zoxide -n "__fish_seen_subcommand_from init" -s V -l version -d 'Print version information'
complete -c zoxide -n "__fish_seen_subcommand_from query" -l exclude -d 'Exclude a path from results' -r -f -a "(__fish_complete_directories)"

View File

@ -31,13 +31,9 @@ const completion: Fig.Spec = {
args: {
name: "from",
suggestions: [
{
name: "autojump",
},
{
name: "z",
},
]
"autojump",
"z",
],
},
},
{
@ -64,7 +60,7 @@ const completion: Fig.Spec = {
options: [
{
name: "--cmd",
description: "Renames the 'z' command and corresponding aliases",
description: "Changes the prefix of the `z` and `zi` commands",
args: {
name: "cmd",
isOptional: true,
@ -72,26 +68,20 @@ const completion: Fig.Spec = {
},
{
name: "--hook",
description: "Chooses event upon which an entry is added to the database",
description: "Changes how often zoxide increments a directory's score",
args: {
name: "hook",
isOptional: true,
suggestions: [
{
name: "none",
},
{
name: "prompt",
},
{
name: "pwd",
},
]
"none",
"prompt",
"pwd",
],
},
},
{
name: "--no-aliases",
description: "Prevents zoxide from defining any commands",
name: "--no-cmd",
description: "Prevents zoxide from defining the `z` and `zi` commands",
},
{
name: ["-h", "--help"],
@ -105,31 +95,15 @@ const completion: Fig.Spec = {
args: {
name: "shell",
suggestions: [
{
name: "bash",
},
{
name: "elvish",
},
{
name: "fish",
},
{
name: "nushell",
},
{
name: "posix",
},
{
name: "powershell",
},
{
name: "xonsh",
},
{
name: "zsh",
},
]
"bash",
"elvish",
"fish",
"nushell",
"posix",
"powershell",
"xonsh",
"zsh",
],
},
},
{
@ -152,14 +126,26 @@ const completion: Fig.Spec = {
{
name: ["-i", "--interactive"],
description: "Use interactive selection",
exclusiveOn: [
"-l",
"--list",
],
},
{
name: ["-l", "--list"],
description: "List all matching directories",
exclusiveOn: [
"-i",
"--interactive",
],
},
{
name: ["-s", "--score"],
description: "Print score with results",
exclusiveOn: [
"-i",
"--interactive",
],
},
{
name: ["-h", "--help"],

View File

@ -74,9 +74,9 @@ Add this to your configuration:
.SH OPTIONS
.TP
.B --cmd
Changes the prefix of predefined aliases (\fBz\fR, \fBzi\fR).
Changes the prefix of the \fBz\fR and \fBzi\fR commands.
.br
\fB--cmd j\fR would change the aliases to (\fBj\fR, \fBji\fR).
\fB--cmd j\fR would change the commands to (\fBj\fR, \fBji\fR).
.br
\fB--cmd cd\fR would replace the \fBcd\fR command (doesn't work on Nushell /
POSIX shells).
@ -94,10 +94,10 @@ l l.
\fBpwd\fR|Whenever the directory is changed
.TE
.TP
.B --no-aliases
Don't define extra aliases (\fBz\fR, \fBzi\fR). These functions will still be
available in your shell as \fB__zoxide_z\fR and \fB__zoxide_zi\fR, should you
choose to redefine them.
.B --no-cmd
Prevents zoxide from defining the \fBz\fR and \fBzi\fR commands. These functions
will still be available in your shell as \fB__zoxide_z\fR and \fB__zoxide_zi\fR,
should you choose to redefine them.
.SH REPORTING BUGS
For any issues, feature requests, or questions, please visit:
.sp

View File

@ -62,15 +62,15 @@ pub struct Init {
#[clap(arg_enum)]
pub shell: InitShell,
/// Prevents zoxide from defining any commands
#[clap(long)]
pub no_aliases: bool,
/// Prevents zoxide from defining the `z` and `zi` commands
#[clap(long, alias = "no-aliases")]
pub no_cmd: bool,
/// Renames the 'z' command and corresponding aliases
/// Changes the prefix of the `z` and `zi` commands
#[clap(long, default_value = "z")]
pub cmd: String,
/// Chooses event upon which an entry is added to the database
/// Changes how often zoxide increments a directory's score
#[clap(arg_enum, long, default_value = "pwd")]
pub hook: InitHook,
}

View File

@ -10,7 +10,7 @@ use crate::shell::{self, Opts};
impl Run for Init {
fn run(&self) -> Result<()> {
let cmd = if self.no_aliases { None } else { Some(self.cmd.as_str()) };
let cmd = if self.no_cmd { None } else { Some(self.cmd.as_str()) };
let echo = config::echo();
let resolve_symlinks = config::resolve_symlinks();

View File

@ -58,7 +58,7 @@ fi
{% endif -%}
{{ section }}
# When using zoxide with --no-aliases, alias these internal functions as
# When using zoxide with --no-cmd, alias these internal functions as
# desired.
#
@ -91,7 +91,7 @@ function __zoxide_zi() {
}
{{ section }}
# Convenient aliases for zoxide. Disable these using --no-aliases.
# Commands for zoxide. Disable these using --no-cmd.
#
{%- match cmd %}

View File

@ -41,7 +41,7 @@ if (builtin:not (builtin:eq $E:__zoxide_shlvl $E:SHLVL)) {
{%- endif %}
{{ section }}
# When using zoxide with --no-aliases, alias these internal functions as
# When using zoxide with --no-cmd, alias these internal functions as
# desired.
#
@ -78,7 +78,7 @@ fn __zoxide_zi {|@rest|
edit:add-var __zoxide_zi~ $__zoxide_zi~
{{ section }}
# Convenient aliases for zoxide. Disable these using --no-aliases.
# Commands for zoxide. Disable these using --no-cmd.
#
{%- match cmd %}

View File

@ -53,7 +53,7 @@ end
{%- endif %}
{{ section }}
# When using zoxide with --no-aliases, alias these internal functions as
# When using zoxide with --no-cmd, alias these internal functions as
# desired.
#
@ -96,7 +96,7 @@ function __zoxide_zi
end
{{ section }}
# Convenient aliases for zoxide. Disable these using --no-aliases.
# Commands for zoxide. Disable these using --no-cmd.
#
{%- match cmd %}

View File

@ -45,7 +45,7 @@ $'zoxide: PWD hooks are not supported on Nushell.(char nl)Use (char sq)zoxide in
{%- endmatch %}
{{ section }}
# When using zoxide with --no-aliases, alias these internal functions as
# When using zoxide with --no-cmd, alias these internal functions as
# desired.
#
@ -86,7 +86,7 @@ def __zoxide_zi [...rest:string] {
}
{{ section }}
# Convenient aliases for zoxide. Disable these using --no-aliases.
# Commands for zoxide. Disable these using --no-cmd.
#
{%- match cmd %}

View File

@ -47,7 +47,7 @@ fi
{%- endmatch %}
{{ section }}
# When using zoxide with --no-aliases, alias these internal functions as
# When using zoxide with --no-cmd, alias these internal functions as
# desired.
#
@ -77,7 +77,7 @@ __zoxide_zi() {
}
{{ section }}
# Convenient aliases for zoxide. Disable these using --no-aliases.
# Commands for zoxide. Disable these using --no-cmd.
#
{%- match cmd %}

View File

@ -67,7 +67,7 @@ if ($__zoxide_hooked -ne 1) {
}
{{ section }}
# When using zoxide with --no-aliases, alias these internal functions as
# When using zoxide with --no-cmd, alias these internal functions as
# desired.
#
@ -105,7 +105,7 @@ function __zoxide_zi {
}
{{ section }}
# Convenient aliases for zoxide. Disable these using --no-aliases.
# Commands for zoxide. Disable these using --no-cmd.
#
{%- match cmd %}

View File

@ -108,7 +108,7 @@ if "__zoxide_hook" not in globals():
{% endif %}
{{ section }}
# When using zoxide with --no-aliases, alias these internal functions as
# When using zoxide with --no-cmd, alias these internal functions as
# desired.
#
@ -157,7 +157,7 @@ def __zoxide_zi(args: typing.List[str]) -> None:
{{ section }}
# Convenient aliases for zoxide. Disable these using --no-aliases.
# Commands for zoxide. Disable these using --no-cmd.
#
{%- match cmd %}

View File

@ -46,7 +46,7 @@ fi
{%- endif %}
{{ section }}
# When using zoxide with --no-aliases, alias these internal functions as
# When using zoxide with --no-cmd, alias these internal functions as
# desired.
#
@ -85,7 +85,7 @@ function __zoxide_zi() {
}
{{ section }}
# Convenient aliases for zoxide. Disable these using --no-aliases.
# Commands for zoxide. Disable these using --no-cmd.
#
{%- match cmd %}