diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fa8b10..1d1b770 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Auto-generated completions for [Fig](https://fig.io/). + ### Fixed - Fix compile errors due to broken `clap` dependency. diff --git a/Cargo.lock b/Cargo.lock index 8ea8f77..27a7497 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -179,6 +179,16 @@ dependencies = [ "clap", ] +[[package]] +name = "clap_generate_fig" +version = "3.0.0-beta.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3482836f06a77604c543ffbf86b0b9b814e5413cec432d75fea9db7eb9bf26d" +dependencies = [ + "clap", + "clap_generate", +] + [[package]] name = "crossbeam-utils" version = "0.8.5" @@ -856,6 +866,7 @@ dependencies = [ "bincode", "clap", "clap_generate", + "clap_generate_fig", "dirs-next", "dunce", "glob", diff --git a/Cargo.toml b/Cargo.toml index c9292bc..13b7e33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ rand = { version = "0.8.4", features = [ [build-dependencies] clap = "=3.0.0-beta.5" clap_generate = "=3.0.0-beta.5" +clap_generate_fig = "=3.0.0-beta.5" [dev-dependencies] assert_cmd = "2.0.0" diff --git a/build.rs b/build.rs index 60434f8..af4adae 100644 --- a/build.rs +++ b/build.rs @@ -39,6 +39,7 @@ fn generate_completions() -> io::Result<()> { use clap::IntoApp; use clap_generate::generate_to; use clap_generate::generators::{Bash, Elvish, Fish, PowerShell, Zsh}; + use clap_generate_fig::Fig; let app = &mut App::into_app(); let bin_name = env!("CARGO_PKG_NAME"); @@ -46,6 +47,7 @@ fn generate_completions() -> io::Result<()> { generate_to(Bash, app, bin_name, out_dir)?; generate_to(Elvish, app, bin_name, out_dir)?; + generate_to(Fig, app, bin_name, out_dir)?; generate_to(Fish, app, bin_name, out_dir)?; generate_to(PowerShell, app, bin_name, out_dir)?; generate_to(Zsh, app, bin_name, out_dir)?; diff --git a/contrib/completions/zoxide.ts b/contrib/completions/zoxide.ts new file mode 100644 index 0000000..0c41a75 --- /dev/null +++ b/contrib/completions/zoxide.ts @@ -0,0 +1,220 @@ +const completion: Fig.Spec = { + name: "zoxide", + description: "A smarter cd command for your terminal", + subcommands: [ + { + name: "add", + description: "Add a new directory or increment its rank", + options: [ + { + name: ["-h", "--help"], + description: "Print help information", + }, + { + name: ["-V", "--version"], + description: "Print version information", + }, + ], + args: { + name: "paths", + isVariadic: true, + template: "folders", + }, + }, + { + name: "import", + description: "Import entries from another application", + options: [ + { + name: "--from", + description: "Application to import from", + args: { + name: "from", + suggestions: [ + { + name: "autojump", + }, + { + name: "z", + }, + ] + }, + }, + { + name: "--merge", + description: "Merge into existing database", + }, + { + name: ["-h", "--help"], + description: "Print help information", + }, + { + name: ["-V", "--version"], + description: "Print version information", + }, + ], + args: { + name: "path", + template: "filepaths", + }, + }, + { + name: "init", + description: "Generate shell configuration", + options: [ + { + name: "--cmd", + description: "Renames the 'z' command and corresponding aliases", + args: { + name: "cmd", + isOptional: true, + }, + }, + { + name: "--hook", + description: "Chooses event upon which an entry is added to the database", + args: { + name: "hook", + isOptional: true, + suggestions: [ + { + name: "none", + }, + { + name: "prompt", + }, + { + name: "pwd", + }, + ] + }, + }, + { + name: "--no-aliases", + description: "Prevents zoxide from defining any commands", + }, + { + name: ["-h", "--help"], + description: "Print help information", + }, + { + name: ["-V", "--version"], + description: "Print version information", + }, + ], + args: { + name: "shell", + suggestions: [ + { + name: "bash", + }, + { + name: "elvish", + }, + { + name: "fish", + }, + { + name: "nushell", + }, + { + name: "posix", + }, + { + name: "powershell", + }, + { + name: "xonsh", + }, + { + name: "zsh", + }, + ] + }, + }, + { + name: "query", + description: "Search for a directory in the database", + options: [ + { + name: "--exclude", + description: "Exclude a path from results", + args: { + name: "exclude", + isOptional: true, + template: "folders", + }, + }, + { + name: "--all", + description: "Show deleted directories", + }, + { + name: ["-i", "--interactive"], + description: "Use interactive selection", + }, + { + name: ["-l", "--list"], + description: "List all matching directories", + }, + { + name: ["-s", "--score"], + description: "Print score with results", + }, + { + name: ["-h", "--help"], + description: "Print help information", + }, + { + name: ["-V", "--version"], + description: "Print version information", + }, + ], + args: { + name: "keywords", + isVariadic: true, + isOptional: true, + }, + }, + { + name: "remove", + description: "Remove a directory from the database", + options: [ + { + name: ["-i", "--interactive"], + args: { + name: "interactive", + isVariadic: true, + isOptional: true, + }, + }, + { + name: ["-h", "--help"], + description: "Print help information", + }, + { + name: ["-V", "--version"], + description: "Print version information", + }, + ], + args: { + name: "paths", + isVariadic: true, + isOptional: true, + template: "folders", + }, + }, + ], + options: [ + { + name: ["-h", "--help"], + description: "Print help information", + }, + { + name: ["-V", "--version"], + description: "Print version information", + }, + ], +}; + +export default completion;