Skip to content
Snippets Groups Projects

gcli command auto completion and arm64 build

Merged Nicolas80 requested to merge gcli-command-auto-completion-and-arm64-build into master
All threads resolved!
5 files
+ 172
6
Compare changes
  • Side-by-side
  • Inline

Files

+ 41
1
@@ -12,14 +12,17 @@ mod utils;
use anyhow::anyhow;
use clap::builder::OsStr;
use clap::Parser;
use clap::{CommandFactory, Parser};
use clap_complete::{generate, Shell};
use codec::Encode;
use colored::Colorize;
use data::*;
use display::DisplayEvent;
use indoc::indoc;
use keys::*;
use runtime_config::*;
use serde::{Deserialize, Serialize};
use std::io;
use std::str::FromStr;
use subxt::{
blocks::ExtrinsicEvents,
@@ -158,6 +161,37 @@ pub enum Subcommand {
/// Publish a new git tag with actual version
#[clap(hide = true)]
Publish,
/// 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)]
shell: Shell,
},
}
/// main function
@@ -171,6 +205,12 @@ async fn main() -> Result<(), GcliError> {
// match subcommands
let result = match data.args.subcommand.clone() {
// handle shell completions
Subcommand::Completion { shell } => {
let mut app = Args::command();
generate(shell, &mut app, "gcli", &mut io::stdout());
return Ok(());
}
Subcommand::Nothing => Ok(()),
Subcommand::Account(subcommand) => {
commands::account::handle_command(data, subcommand).await
Loading