Releases: nihaals/clap-complete-command
Releases · nihaals/clap-complete-command
v0.6.1
v0.6.0
- Removed
fig
from default features - Updated generator dependencies
Full Changelog: v0.5.1...v0.6.0
v0.5.1
Full Changelog: v0.5.0...v0.5.1
v0.5.0
Additions
- Add Nushell behind
nushell
feature (enabled by default) - Add Carapace spec generation behind
carapace
feature
Changes
- Move Fig behind
fig
feature (enabled by default)
Full Changelog: v0.4.0...v0.5.0
v0.4.0
Additions
- Implement
ValueEnum
- Implement
Debug
Breaking changes
- Update Clap to v4
- Remove implementation of
ArgEnum
- Remove methods for pre-
ValueEnum
builder API- Remove
FromStr
implementation - Remove
Shell::possible_values()
- Remove
Migration guide
See the examples diff, including changes needed to update from Clap v3 to v4:
Builder
--- a/examples/builder.rs
+++ b/examples/builder.rs
use clap::{Arg, Command};
-fn build_cli() -> Command<'static> {
+fn build_cli() -> Command {
Command::new(env!("CARGO_PKG_NAME"))
.subcommand_required(true)
.subcommand(
Command::new("completions")
.about("Generate shell completions")
.arg(
Arg::new("shell")
.value_name("SHELL")
.help("The shell to generate the completions for")
.required(true)
- .possible_values(clap_complete_command::Shell::possible_values()),
+ .value_parser(
+ clap::builder::EnumValueParser::<clap_complete_command::Shell>::new(),
+ ),
),
)
}
fn main() {
let matches = build_cli().get_matches();
match matches.subcommand() {
Some(("completions", sub_matches)) => {
- if let Ok(shell) = sub_matches.value_of_t::<clap_complete_command::Shell>("shell") {
+ if let Some(shell) = sub_matches.get_one::<clap_complete_command::Shell>("shell") {
let mut command = build_cli();
shell.generate(&mut command, &mut std::io::stdout());
}
}
_ => {
unreachable!("Exhausted list of subcommands and `subcommand_required` prevents `None`")
}
}
}
Derive
--- a/examples/derive.rs
+++ b/examples/derive.rs
-use clap::{IntoApp, Parser, Subcommand};
+use clap::{CommandFactory, Parser, Subcommand};
#[derive(Parser)]
struct Cli {
- #[clap(subcommand)]
+ #[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
/// Generate shell completions
Completions {
/// The shell to generate the completions for
- #[clap(arg_enum)]
+ #[arg(value_enum)]
shell: clap_complete_command::Shell,
},
}
fn main() {
let cli = Cli::parse();
match cli.command {
Commands::Completions { shell } => {
shell.generate(&mut Cli::command(), &mut std::io::stdout());
}
}
}
Full Changelog: v0.3.4...v0.4.0
v0.3.4
Full Changelog: v0.3.3...v0.3.4
v0.3.3
Full Changelog: v0.3.2...v0.3.3
v0.3.2
Full Changelog: v0.3.1...v0.3.2
v0.3.1
Full Changelog: v0.3.0...v0.3.1
v0.3.0
Full Changelog: v0.2.2...v0.3.0