diff --git a/CHANGELOG.md b/CHANGELOG.md index 20c14a6dc4ce778dcfa1da426e3772a0553472f5..62d39930f84cd38ec3d764ff93bce35cc469b2dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,10 @@ List of changelogs ordered from latest to oldest -## [0.4.2] - 2025-05-12 +## [0.4.2] - 2025-05-16 ### Added / Changed - Extra command `completion` added which takes a `--shell` argument to generate a completions script for a specified shell. + - Calling this command with `gcli completion --help` will provide detailed instructions to generate the completion script and register it for your shell (not necessary when using the `.deb` package that include and registers the completion scripts for `bash`, `zsh` and `fish`) ### CI/CD - Adapted the Linux (amd64) build to: diff --git a/Cargo.toml b/Cargo.toml index 1d1b0b5608e3ed817776d5dc70920c8555791007..2e952bc9668c455c9fe0582ad789672a5734250c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,7 @@ bs58 = "^0.5.1" directories = "^5.0.1" comfy-table = "^7.1.1" sea-orm = { version = "1.1.0", features = [ "sqlx-sqlite", "runtime-tokio-native-tls", "macros" ] } +indoc = "2.0.5" # crypto scrypt = { version = "^0.11", default-features = false } # for old-style key generation @@ -56,7 +57,6 @@ colored = "2.1.0" # Tests rstest = "0.23.0" -indoc = "2.0.5" # allows to build gcli for different runtimes and with different predefined networks [features] diff --git a/src/main.rs b/src/main.rs index 2a0356244692e0a1dcd622e5720a800ea0715e68..8e417d6002ad0fefa59da870cc48aa307b4f7513 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,7 @@ use codec::Encode; use colored::Colorize; use data::*; use display::DisplayEvent; +use indoc::indoc; use keys::*; use runtime_config::*; use serde::{Deserialize, Serialize}; @@ -160,7 +161,32 @@ pub enum Subcommand { /// Publish a new git tag with actual version #[clap(hide = true)] Publish, - /// Generate a completions script for a specified shell + /// Generate a completions script for a specified shell (use `completion --help` for more info) + #[clap(long_about = indoc! {r#"Generate a completions script for a specified shell. + + The base completion scripts for `bash`, `zsh` or `fish` are already registered when installing the `.deb` package. + If you did not/could not install the `.deb` package we can generate the script and then configure the shell to use it. + + Example for `bash`: + mkdir -p ~/.local/share/gcli + gcli completion --shell bash > ~/.local/share/gcli/completion.bash + # Direct test - gcli should have the completion after the source command + source ~/.local/share/gcli/completion.bash + + # Persisting the configuration in the shell configuration file, add this at the end of your `~/.bashrc` file + [[ -f $HOME/.local/share/gcli/completion.bash ]] && source $HOME/.local/share/gcli/completion.bash + # Might need to reopen the shell for the configuration to be applied + + Example for `zsh`: + mkdir -p ~/.local/share/gcli + gcli completion --shell zsh > ~/.local/share/gcli/completion.zsh + # Direct test - gcli should have the completion after the source command + source ~/.local/share/gcli/completion.zsh + + # Persisting the configuration in the shell configuration file, add this at the end of your `~/.zshrc` file + [[ -f $HOME/.local/share/gcli/completion.zsh ]] && source $HOME/.local/share/gcli/completion.zsh + # Might need to reopen the shell for the configuration to be applied + "#})] Completion { /// target shell #[clap(long)]