Fix badge

This commit is contained in:
Ajeet D'Souza 2022-11-15 13:47:37 +05:30
parent c7b8f2f011
commit d99e9b7d86
11 changed files with 39 additions and 52 deletions

View File

@ -9,7 +9,7 @@ license = "MIT"
name = "zoxide"
readme = "README.md"
repository = "https://github.com/ajeetdsouza/zoxide"
rust-version = "1.64"
rust-version = "1.65"
version = "0.8.3"
[badges]

View File

@ -13,7 +13,6 @@
[![crates.io][crates.io-badge]][crates.io]
[![Downloads][downloads-badge]][releases]
[![License][license-badge]][license]
[![Built with Nix][builtwithnix-badge]][builtwithnix]
zoxide is a **smarter cd command**, inspired by z and autojump.
@ -399,7 +398,7 @@ They must be set before `zoxide init` is called.
| [nnn] | File manager | [nnn-autojump] |
| [ranger] | File manager | [ranger-zoxide] |
| [telescope.nvim] | Fuzzy finder for Neovim | [telescope-zoxide] |
| [vim] | Text editor | [zoxide.vim] |
| [vim] / [neovim] | Text editor | [zoxide.vim] |
| [xplr] | File manager | [zoxide.xplr] |
| [xxh] | Transports shell configuration over SSH | [xxh-plugin-prerun-zoxide] |
| [zabb] | Finds the shortest possible query for a path | Natively supported |
@ -409,18 +408,18 @@ They must be set before `zoxide init` is called.
[algorithm-matching]: https://github.com/ajeetdsouza/zoxide/wiki/Algorithm#matching
[alpine linux packages]: https://pkgs.alpinelinux.org/packages?name=zoxide
[arch linux community]: https://archlinux.org/packages/community/x86_64/zoxide/
[builtwithnix-badge]: https://img.shields.io/badge/builtwith-nix-7d81f7?style=flat-square
[builtwithnix-badge]: https://img.shields.io/badge/builtwith-nix-7d81f7?logo=nixos&logoColor=white&style=flat-square
[builtwithnix]: https://builtwithnix.org/
[chocolatey]: https://community.chocolatey.org/packages/zoxide
[clink-zoxide]: https://github.com/shunsambongi/clink-zoxide
[clink]: https://github.com/mridgers/clink
[conda-forge]: https://anaconda.org/conda-forge/zoxide
[copr]: https://copr.fedorainfracloud.org/coprs/atim/zoxide/
[crates.io-badge]: https://img.shields.io/crates/v/zoxide?style=flat-square
[crates.io-badge]: https://img.shields.io/crates/v/zoxide?logo=rust&logoColor=white&style=flat-square
[crates.io]: https://crates.io/crates/zoxide
[debian packages]: https://packages.debian.org/stable/admin/zoxide
[devuan packages]: https://pkginfo.devuan.org/cgi-bin/package-query.html?c=package&q=zoxide
[downloads-badge]: https://img.shields.io/endpoint?color=bright-green&label=downloads&style=flat-square&cacheSeconds=3600&url=https%3A%2F%2Fzoxide-dl-rlvir7rbe5ac.runkit.sh%2F
[downloads-badge]: https://img.shields.io/github/downloads/ajeetdsouza/zoxide/total?logo=github&logoColor=white&style=flat-square
[dports]: https://github.com/DragonFlyBSD/DPorts/tree/master/sysutils/zoxide
[emacs]: https://www.gnu.org/software/emacs/
[fedora packages]: https://src.fedoraproject.org/rpms/rust-zoxide
@ -436,8 +435,6 @@ They must be set before `zoxide init` is called.
[joshuto]: https://github.com/kamiyaa/joshuto
[lf]: https://github.com/gokcehan/lf
[lf-wiki]: https://github.com/gokcehan/lf/wiki/Integrations#zoxide
[license-badge]: https://img.shields.io/github/license/ajeetdsouza/zoxide?color=lightgray&style=flat-square
[license]: https://github.com/ajeetdsouza/zoxide/blob/main/LICENSE
[linuxbrew]: https://formulae.brew.sh/formula-linux/zoxide
[macports]: https://ports.macports.org/port/zoxide/summary
[neovim]: https://github.com/neovim/neovim

View File

@ -22,7 +22,7 @@ fn main() {
fn git_version() -> Option<String> {
let dir = env!("CARGO_MANIFEST_DIR");
let mut git = Command::new("git");
git.args(&["-C", dir, "describe", "--tags", "--match=v*.*.*", "--always", "--broken"]);
git.args(["-C", dir, "describe", "--tags", "--match=v*.*.*", "--always", "--broken"]);
let output = git.output().ok()?;
if !output.status.success() || output.stdout.is_empty() || !output.stderr.is_empty() {

View File

@ -1,6 +1,6 @@
let
rust = import (builtins.fetchTarball
"https://github.com/oxalica/rust-overlay/archive/34d76c0a001d81a0fac342698ce7926da37b8ea5.tar.gz");
"https://github.com/oxalica/rust-overlay/archive/2342f70f7257046effc031333c4cfdea66c91d82.tar.gz");
pkgs = import (builtins.fetchTarball
"https://github.com/NixOS/nixpkgs/archive/0323e1f8bac882f19905174639a89397db1930f1.tar.gz") {
overlays = [ rust ];

View File

@ -35,11 +35,7 @@ impl Query {
let stdin = fzf.stdin();
let selection = loop {
let dir = match stream.next() {
Some(dir) => dir,
None => break fzf.select()?,
};
let Some(dir) = stream.next() else { break fzf.select()? };
match writeln!(stdin, "{}", dir.display_score(now)) {
Err(e) if e.kind() == io::ErrorKind::BrokenPipe => break fzf.select()?,
result => result.context("could not write to fzf")?,

View File

@ -22,11 +22,7 @@ impl Run for Remove {
let stdin = fzf.stdin();
let selection = loop {
let dir = match stream.next() {
Some(dir) => dir,
None => break fzf.select()?,
};
let Some(dir) = stream.next() else { break fzf.select()? };
match writeln!(stdin, "{}", dir.display_score(now)) {
Err(e) if e.kind() == io::ErrorKind::BrokenPipe => break fzf.select()?,
result => result.context("could not write to fzf")?,

View File

@ -24,7 +24,7 @@ impl<'file> Database<'file> {
}
let buffer = self.dirs.to_bytes()?;
let path = db_path(&self.data_dir);
let path = db_path(self.data_dir);
util::write(&path, &buffer).context("could not write to database")?;
self.modified = false;
Ok(())
@ -35,13 +35,11 @@ impl<'file> Database<'file> {
let path = path.as_ref();
match self.dirs.iter_mut().find(|dir| dir.path == path) {
None => {
self.dirs.push(Dir { path: path.to_string().into(), last_accessed: now, rank: 1.0 });
}
Some(dir) => {
dir.last_accessed = now;
dir.rank += 1.0;
}
None => self.dirs.push(Dir { path: path.to_string().into(), last_accessed: now, rank: 1.0 }),
};
self.modified = true;

View File

@ -57,7 +57,7 @@ mod tests {
let opts = Opts { cmd, hook, echo, resolve_symlinks };
let source = Bash(&opts).render().unwrap();
Command::new("bash")
.args(&["--noprofile", "--norc", "-e", "-u", "-o", "pipefail", "-c", &source])
.args(["--noprofile", "--norc", "-e", "-u", "-o", "pipefail", "-c", &source])
.assert()
.success()
.stdout("")
@ -70,7 +70,7 @@ mod tests {
let source = Bash(&opts).render().unwrap();
Command::new("shellcheck")
.args(&["--enable", "all", "--shell", "bash", "-"])
.args(["--enable", "all", "--shell", "bash", "-"])
.write_stdin(source)
.assert()
.success()
@ -85,7 +85,7 @@ mod tests {
source.push('\n');
Command::new("shfmt")
.args(&["-d", "-s", "-ln", "bash", "-i", "4", "-ci", "-"])
.args(["-d", "-s", "-ln", "bash", "-i", "4", "-ci", "-"])
.write_stdin(source)
.assert()
.success()
@ -105,7 +105,7 @@ mod tests {
source.push('\n');
}
Command::new("elvish").args(&["-c", &source, "-norc"]).assert().success().stdout("").stderr("");
Command::new("elvish").args(["-c", &source, "-norc"]).assert().success().stdout("").stderr("");
}
#[apply(opts)]
@ -118,7 +118,7 @@ mod tests {
Command::new("fish")
.env("HOME", tempdir)
.args(&["--command", &source, "--private"])
.args(["--command", &source, "--no-config", "--private"])
.assert()
.success()
.stdout("")
@ -152,7 +152,7 @@ mod tests {
let tempdir = tempdir.path();
let assert =
Command::new("nu").env("HOME", tempdir).args(&["--commands", &source]).assert().success().stderr("");
Command::new("nu").env("HOME", tempdir).args(["--commands", &source]).assert().success().stderr("");
if opts.hook != InitHook::Pwd {
assert.stdout("");
@ -165,7 +165,7 @@ mod tests {
let source = Posix(&opts).render().unwrap();
let assert = Command::new("bash")
.args(&["--posix", "--noprofile", "--norc", "-e", "-u", "-o", "pipefail", "-c", &source])
.args(["--posix", "--noprofile", "--norc", "-e", "-u", "-o", "pipefail", "-c", &source])
.assert()
.success()
.stderr("");
@ -179,7 +179,7 @@ mod tests {
let opts = Opts { cmd, hook, echo, resolve_symlinks };
let source = Posix(&opts).render().unwrap();
let assert = Command::new("dash").args(&["-e", "-u", "-c", &source]).assert().success().stderr("");
let assert = Command::new("dash").args(["-e", "-u", "-c", &source]).assert().success().stderr("");
if opts.hook != InitHook::Pwd {
assert.stdout("");
}
@ -191,7 +191,7 @@ mod tests {
let source = Posix(&opts).render().unwrap();
Command::new("shellcheck")
.args(&["--enable", "all", "--shell", "sh", "-"])
.args(["--enable", "all", "--shell", "sh", "-"])
.write_stdin(source)
.assert()
.success()
@ -206,7 +206,7 @@ mod tests {
source.push('\n');
Command::new("shfmt")
.args(&["-d", "-s", "-ln", "posix", "-i", "4", "-ci", "-"])
.args(["-d", "-s", "-ln", "posix", "-i", "4", "-ci", "-"])
.write_stdin(source)
.assert()
.success()
@ -221,7 +221,7 @@ mod tests {
Powershell(&opts).render_into(&mut source).unwrap();
Command::new("pwsh")
.args(&["-NoLogo", "-NonInteractive", "-NoProfile", "-Command", &source])
.args(["-NoLogo", "-NonInteractive", "-NoProfile", "-Command", &source])
.assert()
.success()
.stdout("")
@ -234,7 +234,7 @@ mod tests {
let mut source = Xonsh(&opts).render().unwrap();
source.push('\n');
Command::new("black").args(&["--check", "--diff", "-"]).write_stdin(source).assert().success().stdout("");
Command::new("black").args(["--check", "--diff", "-"]).write_stdin(source).assert().success().stdout("");
}
#[apply(opts)]
@ -242,7 +242,7 @@ mod tests {
let opts = Opts { cmd, hook, echo, resolve_symlinks };
let source = Xonsh(&opts).render().unwrap();
Command::new("mypy").args(&["--command", &source, "--strict"]).assert().success().stderr("");
Command::new("mypy").args(["--command", &source, "--strict"]).assert().success().stderr("");
}
#[apply(opts)]
@ -252,7 +252,7 @@ mod tests {
source.push('\n');
Command::new("pylint")
.args(&["--from-stdin", "--persistent=n", "zoxide"])
.args(["--from-stdin", "--persistent=n", "zoxide"])
.write_stdin(source)
.assert()
.success()
@ -268,7 +268,7 @@ mod tests {
let tempdir = tempdir.path().to_str().unwrap();
Command::new("xonsh")
.args(&["-c", &source, "--no-rc"])
.args(["-c", &source, "--no-rc"])
.env("HOME", tempdir)
.assert()
.success()
@ -283,7 +283,7 @@ mod tests {
// ShellCheck doesn't support zsh yet: https://github.com/koalaman/shellcheck/issues/809
Command::new("shellcheck")
.args(&["--enable", "all", "--shell", "bash", "-"])
.args(["--enable", "all", "--shell", "bash", "-"])
.write_stdin(source)
.assert()
.success()
@ -297,7 +297,7 @@ mod tests {
let source = Zsh(&opts).render().unwrap();
Command::new("zsh")
.args(&["-e", "-u", "-o", "pipefail", "--no-globalrcs", "--no-rcs", "-c", &source])
.args(["-e", "-u", "-o", "pipefail", "--no-globalrcs", "--no-rcs", "-c", &source])
.assert()
.success()
.stdout("")

View File

@ -36,7 +36,7 @@ impl Fzf {
if let Some(fzf_opts) = config::fzf_opts() {
command.env("FZF_DEFAULT_OPTS", fzf_opts);
} else {
command.args(&[
command.args([
// Search result
"--no-sort",
// Interface
@ -58,7 +58,7 @@ impl Fzf {
} else {
r"\command -p ls -Cp {2..}"
};
command.args(&["--preview", PREVIEW_CMD, "--preview-window=down,30%"]).env("SHELL", "sh");
command.args(["--preview", PREVIEW_CMD, "--preview-window=down,30%"]).env("SHELL", "sh");
}
}

View File

@ -6,7 +6,7 @@ use assert_cmd::Command;
#[test]
fn completions_bash() {
let source = include_str!("../contrib/completions/zoxide.bash");
Command::new("bash").args(&["--noprofile", "--norc", "-c", source]).assert().success().stdout("").stderr("");
Command::new("bash").args(["--noprofile", "--norc", "-c", source]).assert().success().stdout("").stderr("");
}
// Elvish: the completions file uses editor commands to add completions to the shell. However,
@ -21,7 +21,7 @@ fn completions_fish() {
Command::new("fish")
.env("HOME", tempdir)
.args(&["--command", source, "--private"])
.args(["--command", source, "--private"])
.assert()
.success()
.stdout("")
@ -32,7 +32,7 @@ fn completions_fish() {
fn completions_powershell() {
let source = include_str!("../contrib/completions/_zoxide.ps1");
Command::new("pwsh")
.args(&["-NoLogo", "-NonInteractive", "-NoProfile", "-Command", source])
.args(["-NoLogo", "-NonInteractive", "-NoProfile", "-Command", source])
.assert()
.success()
.stdout("")
@ -50,5 +50,5 @@ fn completions_zsh() {
compinit -u
"#;
Command::new("zsh").args(&["-c", source, "--no-rcs"]).assert().success().stdout("").stderr("");
Command::new("zsh").args(["-c", source, "--no-rcs"]).assert().success().stdout("").stderr("");
}

View File

@ -55,7 +55,7 @@ impl CommandExt for &mut Command {
fn run_ci(nix_enabled: bool) -> Result<()> {
// Run cargo-clippy.
Command::new("cargo").args(&["clippy", "--all-features", "--all-targets"]).args(&["--", "-Dwarnings"]).run()?;
Command::new("cargo").args(["clippy", "--all-features", "--all-targets"]).args(["--", "-Dwarnings"]).run()?;
run_fmt(nix_enabled, true)?;
run_lint(nix_enabled)?;
run_tests(nix_enabled, "")
@ -84,7 +84,7 @@ fn run_fmt(nix_enabled: bool, check: bool) -> Result<()> {
fn run_lint(nix_enabled: bool) -> Result<()> {
if nix_enabled {
// Run cargo-audit.
Command::new("cargo").args(&["audit", "--deny=warnings"]).run()?;
Command::new("cargo").args(["audit", "--deny=warnings"]).run()?;
// Run markdownlint.
for result in Walk::new("./") {
@ -100,7 +100,7 @@ fn run_lint(nix_enabled: bool) -> Result<()> {
let entry = result.unwrap();
let path = entry.path();
if path.is_file() && path.extension() == Some(OsStr::new("1")) {
Command::new("mandoc").args(&["-man", "-Wall", "-Tlint", "--"]).arg(path).run()?;
Command::new("mandoc").args(["-man", "-Wall", "-Tlint", "--"]).arg(path).run()?;
}
}
}
@ -110,7 +110,7 @@ fn run_lint(nix_enabled: bool) -> Result<()> {
fn run_tests(nix_enabled: bool, name: &str) -> Result<()> {
let args: &[&str] = if nix_enabled { &["nextest", "run", "--all-features"] } else { &["test"] };
Command::new("cargo").args(args).args(&["--no-fail-fast", "--workspace", "--", name]).run()
Command::new("cargo").args(args).args(["--no-fail-fast", "--workspace", "--", name]).run()
}
fn enable_nix() -> bool {
@ -131,6 +131,6 @@ fn enable_nix() -> bool {
let args = env::args();
let cmd = shell_words::join(args);
let status = Command::new("nix-shell").args(&["--pure", "--run", &cmd, "--", "shell.nix"]).status().unwrap();
let status = Command::new("nix-shell").args(["--pure", "--run", &cmd, "--", "shell.nix"]).status().unwrap();
process::exit(status.code().unwrap_or(1));
}