From 54edbf49296e1a26fa5a065d41469271dcc692f7 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Thu, 18 Jul 2024 21:45:31 +0530 Subject: [PATCH 1/8] feat(nixci): add shell completions --- Cargo.lock | 52 ++++++++++++++++++++++++++++++++++++----------- Cargo.toml | 2 ++ flake.nix | 7 +++++++ src/cli.rs | 14 +++++++++++++ src/completion.rs | 38 ++++++++++++++++++++++++++++++++++ src/lib.rs | 8 ++++++++ 6 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 src/completion.rs diff --git a/Cargo.lock b/Cargo.lock index 5521ef4..02b8a2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,6 +111,17 @@ dependencies = [ "wait-timeout", ] +[[package]] +name = "async-trait" +version = "0.1.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -212,9 +223,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.7" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -222,21 +233,30 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.7" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim", + "strsim 0.11.1", +] + +[[package]] +name = "clap_complete" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b4be9c4c4b1f30b78d8a750e0822b6a6102d97e62061c583a6c1dea2dfb33ae" +dependencies = [ + "clap", ] [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ "heck", "proc-macro2", @@ -246,9 +266,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "colorchoice" @@ -346,7 +366,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim", + "strsim 0.10.0", "syn", ] @@ -563,9 +583,9 @@ checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" @@ -943,7 +963,9 @@ version = "0.5.0" dependencies = [ "anyhow", "assert_cmd", + "async-trait", "clap", + "clap_complete", "colored", "ctor", "nix_health", @@ -1513,6 +1535,12 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "syn" version = "2.0.58" diff --git a/Cargo.toml b/Cargo.toml index ba33c39..1ccad30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,8 @@ nix_rs = { version = "0.5.0", features = ["clap"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } tracing = "0.1.37" nix_health = "0.4.1" +clap_complete = "4.4.0" +async-trait = "0.1.73" [dev-dependencies] regex = "1.9" diff --git a/flake.nix b/flake.nix index ec0e633..87da382 100644 --- a/flake.nix +++ b/flake.nix @@ -46,6 +46,7 @@ ] ++ [ libiconv pkg-config + installShellFiles ]; buildInputs = lib.optionals pkgs.stdenv.isDarwin ( @@ -60,6 +61,12 @@ pkgs.openssl ]; DEVOUR_FLAKE = inputs.devour-flake; + postInstall = '' + installShellCompletion --cmd am \ + --bash <("$out/bin/nixci" completion bash) \ + --zsh <("$out/bin/nixci" completion zsh) \ + --fish <("$out/bin/nixci" completion fish) + ''; }; pre-commit = { diff --git a/src/cli.rs b/src/cli.rs index 339f48d..52c3f9f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -108,6 +108,19 @@ pub enum Command { #[arg(long, value_parser, value_delimiter = ',')] systems: Vec, }, + + /// Generates shell completion scripts + Completion { + #[arg(value_enum)] + shell: clap_complete::Shell, + + /// Flake URL or github URL + /// + /// A specific nixci configuration can be specified + /// using '#': e.g. `nixci .#extra-tests` + #[arg(default_value = ".")] + flake_ref: FlakeRef, + }, } impl Command { @@ -116,6 +129,7 @@ impl Command { let flake_ref = match self { Command::Build(build_cfg) => &build_cfg.flake_ref, Command::DumpGithubActionsMatrix { flake_ref, .. } => flake_ref, + Command::Completion { flake_ref, .. } => flake_ref, }; let url = flake_ref.to_flake_url().await?; tracing::info!("{}", format!("🍏 {}", url.0).bold()); diff --git a/src/completion.rs b/src/completion.rs new file mode 100644 index 0000000..baad260 --- /dev/null +++ b/src/completion.rs @@ -0,0 +1,38 @@ +use crate::cli::CliArgs; +use async_trait::async_trait; +use clap::{CommandFactory, Parser}; +use clap_complete::{generate, Shell}; +// use color_eyre::Result; +use anyhow::Result; +use std::io::stdout; +use std::process::ExitCode; + +/// Prints completion for shells to use. +#[derive(Parser)] +pub(crate) struct CompletionSubcommand { + /// Shell + #[arg(value_enum)] + shell: Shell, +} + +#[async_trait] +pub trait CommandExecute { + async fn execute(self) -> Result; +} + +impl CompletionSubcommand { + pub fn new(shell: Shell) -> Self { + Self { shell } + } +} + +#[async_trait] +impl CommandExecute for CompletionSubcommand { + async fn execute(self) -> Result { + let mut cli = CliArgs::command(); + let cli_name = cli.get_name().to_string(); + generate(self.shell, &mut cli, cli_name, &mut stdout()); + + Ok(ExitCode::SUCCESS) + } +} diff --git a/src/lib.rs b/src/lib.rs index 30dce4b..072066c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ pub mod cli; +mod completion; pub mod config; pub mod github; pub mod logging; @@ -17,6 +18,8 @@ use nix_health::{traits::Checkable, NixHealth}; use nix_rs::{command::NixCmd, config::NixConfig, flake::url::FlakeUrl, info::NixInfo}; use tracing::instrument; +use completion::{CommandExecute, CompletionSubcommand}; + /// Run nixci on the given [CliArgs], returning the built outputs in sorted order. #[instrument(name = "nixci", skip(args))] pub async fn nixci(args: CliArgs) -> anyhow::Result> { @@ -44,6 +47,11 @@ pub async fn nixci(args: CliArgs) -> anyhow::Result> { println!("{}", serde_json::to_string(&matrix)?); Ok(vec![]) } + cli::Command::Completion { shell, .. } => { + let cmd = CompletionSubcommand::new(shell); + cmd.execute().await?; + Ok(vec![]) + } } } From 5152d2ae0630bd9bc79643dcf9af23f154f64060 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 19 Jul 2024 01:04:33 +0530 Subject: [PATCH 2/8] refactor: removed redundant code; call get_config when required --- src/cli.rs | 40 ++++++++++++++++++---------------------- src/completion.rs | 38 -------------------------------------- src/lib.rs | 17 +++++++++-------- 3 files changed, 27 insertions(+), 68 deletions(-) delete mode 100644 src/completion.rs diff --git a/src/cli.rs b/src/cli.rs index 52c3f9f..5ccb533 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,14 +1,5 @@ use std::str::FromStr; -use anyhow::Result; -use clap::{Parser, Subcommand}; -use colored::Colorize; -use nix_rs::{ - command::NixCmd, - config::NixConfig, - flake::{system::System, url::FlakeUrl}, -}; - use crate::{ config, github::pull_request::{PullRequest, PullRequestRef}, @@ -17,6 +8,17 @@ use crate::{ system_list::{SystemsList, SystemsListFlakeRef}, }, }; +use anyhow::Result; +use clap::CommandFactory; +use clap::{Parser, Subcommand}; +use clap_complete::{generate, Shell}; +use colored::Colorize; +use nix_rs::{ + command::NixCmd, + config::NixConfig, + flake::{system::System, url::FlakeUrl}, +}; +use std::io; /// A reference to some flake living somewhere #[derive(Debug, Clone, PartialEq, Eq)] @@ -113,30 +115,24 @@ pub enum Command { Completion { #[arg(value_enum)] shell: clap_complete::Shell, - - /// Flake URL or github URL - /// - /// A specific nixci configuration can be specified - /// using '#': e.g. `nixci .#extra-tests` - #[arg(default_value = ".")] - flake_ref: FlakeRef, }, } impl Command { /// Get the nixci [config::Config] associated with this subcommand - pub async fn get_config(&self, cmd: &NixCmd) -> anyhow::Result { - let flake_ref = match self { - Command::Build(build_cfg) => &build_cfg.flake_ref, - Command::DumpGithubActionsMatrix { flake_ref, .. } => flake_ref, - Command::Completion { flake_ref, .. } => flake_ref, - }; + pub async fn get_config(cmd: &NixCmd, flake_ref: &FlakeRef) -> anyhow::Result { let url = flake_ref.to_flake_url().await?; tracing::info!("{}", format!("🍏 {}", url.0).bold()); let cfg = config::Config::from_flake_url(cmd, &url).await?; tracing::debug!("Config: {cfg:?}"); Ok(cfg) } + + pub fn generate_completion(shell: Shell) { + let mut cli = CliArgs::command(); + let name = cli.get_name().to_string(); + generate(shell, &mut cli, name, &mut io::stdout()); + } } #[derive(Parser, Debug)] diff --git a/src/completion.rs b/src/completion.rs deleted file mode 100644 index baad260..0000000 --- a/src/completion.rs +++ /dev/null @@ -1,38 +0,0 @@ -use crate::cli::CliArgs; -use async_trait::async_trait; -use clap::{CommandFactory, Parser}; -use clap_complete::{generate, Shell}; -// use color_eyre::Result; -use anyhow::Result; -use std::io::stdout; -use std::process::ExitCode; - -/// Prints completion for shells to use. -#[derive(Parser)] -pub(crate) struct CompletionSubcommand { - /// Shell - #[arg(value_enum)] - shell: Shell, -} - -#[async_trait] -pub trait CommandExecute { - async fn execute(self) -> Result; -} - -impl CompletionSubcommand { - pub fn new(shell: Shell) -> Self { - Self { shell } - } -} - -#[async_trait] -impl CommandExecute for CompletionSubcommand { - async fn execute(self) -> Result { - let mut cli = CliArgs::command(); - let cli_name = cli.get_name().to_string(); - generate(self.shell, &mut cli, cli_name, &mut stdout()); - - Ok(ExitCode::SUCCESS) - } -} diff --git a/src/lib.rs b/src/lib.rs index 072066c..557a264 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,4 @@ pub mod cli; -mod completion; pub mod config; pub mod github; pub mod logging; @@ -7,7 +6,8 @@ pub mod nix; use std::collections::HashSet; -use anyhow::Context; +use anyhow::{Context, Ok}; + use cli::{BuildConfig, CliArgs}; use colored::Colorize; use nix::{ @@ -18,15 +18,14 @@ use nix_health::{traits::Checkable, NixHealth}; use nix_rs::{command::NixCmd, config::NixConfig, flake::url::FlakeUrl, info::NixInfo}; use tracing::instrument; -use completion::{CommandExecute, CompletionSubcommand}; - /// Run nixci on the given [CliArgs], returning the built outputs in sorted order. #[instrument(name = "nixci", skip(args))] pub async fn nixci(args: CliArgs) -> anyhow::Result> { tracing::debug!("Args: {args:?}"); - let cfg = args.command.get_config(&args.nixcmd).await?; + match args.command { cli::Command::Build(build_cfg) => { + let cfg = cli::Command::get_config(&args.nixcmd, &build_cfg.flake_ref).await?; let nix_info = NixInfo::from_nix(&args.nixcmd) .await .with_context(|| "Unable to gather nix info")?; @@ -42,14 +41,16 @@ pub async fn nixci(args: CliArgs) -> anyhow::Result> { ) .await } - cli::Command::DumpGithubActionsMatrix { systems, .. } => { + cli::Command::DumpGithubActionsMatrix { + systems, flake_ref, .. + } => { + let cfg = cli::Command::get_config(&args.nixcmd, &flake_ref).await?; let matrix = github::matrix::GitHubMatrix::from(systems, &cfg.subflakes); println!("{}", serde_json::to_string(&matrix)?); Ok(vec![]) } cli::Command::Completion { shell, .. } => { - let cmd = CompletionSubcommand::new(shell); - cmd.execute().await?; + cli::Command::generate_completion(shell); Ok(vec![]) } } From 9a29f1a1f0769a42823518a707cf9da6f52e9921 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 19 Jul 2024 01:26:27 +0530 Subject: [PATCH 3/8] refactor: no need for a separate function --- src/cli.rs | 9 --------- src/lib.rs | 10 +++++++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 5ccb533..16e029c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -9,16 +9,13 @@ use crate::{ }, }; use anyhow::Result; -use clap::CommandFactory; use clap::{Parser, Subcommand}; -use clap_complete::{generate, Shell}; use colored::Colorize; use nix_rs::{ command::NixCmd, config::NixConfig, flake::{system::System, url::FlakeUrl}, }; -use std::io; /// A reference to some flake living somewhere #[derive(Debug, Clone, PartialEq, Eq)] @@ -127,12 +124,6 @@ impl Command { tracing::debug!("Config: {cfg:?}"); Ok(cfg) } - - pub fn generate_completion(shell: Shell) { - let mut cli = CliArgs::command(); - let name = cli.get_name().to_string(); - generate(shell, &mut cli, name, &mut io::stdout()); - } } #[derive(Parser, Debug)] diff --git a/src/lib.rs b/src/lib.rs index 557a264..e2e494a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,9 +4,11 @@ pub mod github; pub mod logging; pub mod nix; -use std::collections::HashSet; - use anyhow::{Context, Ok}; +use clap::CommandFactory; +use clap_complete::generate; +use std::collections::HashSet; +use std::io; use cli::{BuildConfig, CliArgs}; use colored::Colorize; @@ -50,7 +52,9 @@ pub async fn nixci(args: CliArgs) -> anyhow::Result> { Ok(vec![]) } cli::Command::Completion { shell, .. } => { - cli::Command::generate_completion(shell); + let mut cli = CliArgs::command(); + let name = cli.get_name().to_string(); + generate(shell, &mut cli, name, &mut io::stdout()); Ok(vec![]) } } From 746b9a5dd5fda00291221c9b7cc19fc5c7c77f45 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Fri, 19 Jul 2024 17:06:20 +0530 Subject: [PATCH 4/8] fix: fixed typo --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 87da382..2e1f181 100644 --- a/flake.nix +++ b/flake.nix @@ -62,7 +62,7 @@ ]; DEVOUR_FLAKE = inputs.devour-flake; postInstall = '' - installShellCompletion --cmd am \ + installShellCompletion --cmd nixci \ --bash <("$out/bin/nixci" completion bash) \ --zsh <("$out/bin/nixci" completion zsh) \ --fish <("$out/bin/nixci" completion fish) From 0e504761ac98ee1bca27143be5e1d2b835a19bf4 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Tue, 23 Jul 2024 01:55:30 +0530 Subject: [PATCH 5/8] feat(nixci): make shell completion script available after install --- flake.nix | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/flake.nix b/flake.nix index 2e1f181..9664150 100644 --- a/flake.nix +++ b/flake.nix @@ -46,7 +46,6 @@ ] ++ [ libiconv pkg-config - installShellFiles ]; buildInputs = lib.optionals pkgs.stdenv.isDarwin ( @@ -61,12 +60,6 @@ pkgs.openssl ]; DEVOUR_FLAKE = inputs.devour-flake; - postInstall = '' - installShellCompletion --cmd nixci \ - --bash <("$out/bin/nixci" completion bash) \ - --zsh <("$out/bin/nixci" completion zsh) \ - --fish <("$out/bin/nixci" completion fish) - ''; }; pre-commit = { @@ -85,7 +78,21 @@ }; # Flake outputs - packages.default = self'.packages.nixci; + packages = + let + inherit (config.rust-project) crates; + in + { + default = self'.packages.nixci.overrideAttrs (oa: { + nativeBuildInputs = (oa.nativeBuildInputs or [ ]) ++ [ pkgs.installShellFiles pkgs.nix ]; + postInstall = '' + installShellCompletion --cmd nixci \ + --bash <($out/bin/nixci completion bash) \ + --zsh <($out/bin/nixci completion zsh) \ + --fish <($out/bin/nixci completion fish) + ''; + }); + }; overlayAttrs.nixci = self'.packages.default; devShells.default = pkgs.mkShell { From 6265e3b3be534b98b0105dc50e8c203148031081 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Tue, 23 Jul 2024 01:59:12 +0530 Subject: [PATCH 6/8] refactor: minor refactor; removed unwanted code --- flake.nix | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/flake.nix b/flake.nix index 9664150..bf19920 100644 --- a/flake.nix +++ b/flake.nix @@ -78,21 +78,15 @@ }; # Flake outputs - packages = - let - inherit (config.rust-project) crates; - in - { - default = self'.packages.nixci.overrideAttrs (oa: { - nativeBuildInputs = (oa.nativeBuildInputs or [ ]) ++ [ pkgs.installShellFiles pkgs.nix ]; - postInstall = '' - installShellCompletion --cmd nixci \ - --bash <($out/bin/nixci completion bash) \ - --zsh <($out/bin/nixci completion zsh) \ - --fish <($out/bin/nixci completion fish) - ''; - }); - }; + packages.default = self'.packages.nixci.overrideAttrs (oa: { + nativeBuildInputs = (oa.nativeBuildInputs or [ ]) ++ [ pkgs.installShellFiles pkgs.nix ]; + postInstall = '' + installShellCompletion --cmd nixci \ + --bash <($out/bin/nixci completion bash) \ + --zsh <($out/bin/nixci completion zsh) \ + --fish <($out/bin/nixci completion fish) + ''; + }); overlayAttrs.nixci = self'.packages.default; devShells.default = pkgs.mkShell { From 7f7e135c87fdcaedce25a7934773536b858933e2 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Tue, 23 Jul 2024 12:41:16 +0530 Subject: [PATCH 7/8] refactor: remove unused dependency; undo the re-arrangements of imports --- Cargo.lock | 12 ------------ Cargo.toml | 1 - src/cli.rs | 17 +++++++++-------- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02b8a2f..f465eb0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,17 +111,6 @@ dependencies = [ "wait-timeout", ] -[[package]] -name = "async-trait" -version = "0.1.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -963,7 +952,6 @@ version = "0.5.0" dependencies = [ "anyhow", "assert_cmd", - "async-trait", "clap", "clap_complete", "colored", diff --git a/Cargo.toml b/Cargo.toml index 1ccad30..c1f5b30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,6 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } tracing = "0.1.37" nix_health = "0.4.1" clap_complete = "4.4.0" -async-trait = "0.1.73" [dev-dependencies] regex = "1.9" diff --git a/src/cli.rs b/src/cli.rs index 16e029c..c14f4ab 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,13 +1,5 @@ use std::str::FromStr; -use crate::{ - config, - github::pull_request::{PullRequest, PullRequestRef}, - nix::{ - devour_flake, - system_list::{SystemsList, SystemsListFlakeRef}, - }, -}; use anyhow::Result; use clap::{Parser, Subcommand}; use colored::Colorize; @@ -17,6 +9,15 @@ use nix_rs::{ flake::{system::System, url::FlakeUrl}, }; +use crate::{ + config, + github::pull_request::{PullRequest, PullRequestRef}, + nix::{ + devour_flake, + system_list::{SystemsList, SystemsListFlakeRef}, + }, +}; + /// A reference to some flake living somewhere #[derive(Debug, Clone, PartialEq, Eq)] pub enum FlakeRef { From a8f01a6050bfa9f07b42c9a16f190a2b7616c780 Mon Sep 17 00:00:00 2001 From: Rohit Singh Date: Tue, 23 Jul 2024 16:24:43 +0530 Subject: [PATCH 8/8] refactor: remove extra arguments as they don't exist --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index e2e494a..458c361 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,7 +51,7 @@ pub async fn nixci(args: CliArgs) -> anyhow::Result> { println!("{}", serde_json::to_string(&matrix)?); Ok(vec![]) } - cli::Command::Completion { shell, .. } => { + cli::Command::Completion { shell } => { let mut cli = CliArgs::command(); let name = cli.get_name().to_string(); generate(shell, &mut cli, name, &mut io::stdout());