Commit 49d8542f31

49d8542f31265ee144d38de61bdd74f92e516860

parent: cbd361d947

Unregistered key

Jon Heinritz <jon.heinritz@protonmail.com> · 2026-07-24 19:30 UTC
committer: <noreply@github.com>

Support generating shell-completions using `clap_complete` (#489)

Layout: unified · split

Cargo.lock +10
@@ -883,6 +883,15 @@ dependencies = [
883883 "strsim",
884884]
885885
886[[package]]
887name = "clap_complete"
888version = "4.6.7"
889source = "registry+https://github.com/rust-lang/crates.io-index"
890checksum = "db8b397918185f0161ff3d6fcaa9e4bfc09b8367caf6e1d4a2848e5477ed027b"
891dependencies = [
892 "clap",
893]
894
886895[[package]]
887896name = "clap_derive"
888897version = "4.6.1"
@@ -2349,6 +2358,7 @@ dependencies = [
23492358 "bitflags 2.13.0",
23502359 "chrono",
23512360 "clap",
2361 "clap_complete",
23522362 "comrak",
23532363 "css-color-parser",
23542364 "dirs",
Cargo.toml +2 −1
@@ -28,7 +28,8 @@ features = ["build"]
2828anyhow = "1.0"
2929bitflags = "2.3"
3030chrono = "0.4"
31clap = {version = "4.3", features = ["derive"]}
31clap = {version = "^4.6", features = ["derive"]}
32clap_complete = "^4.6"
3233css-color-parser = "0.1.2"
3334dirs = "6.0"
3435edit = "0.1.4"
src/config.rs +3
@@ -129,6 +129,9 @@ const VERSION: &str = match option_env!("VERGEN_GIT_SHA") {
129129#[clap(version = VERSION, about, long_about = None)]
130130#[clap(propagate_version = true)]
131131pub struct Iamb {
132 #[clap(long, value_parser)]
133 pub completions: Option<clap_complete::Shell>,
134
132135 #[clap(short = 'P', long, value_parser)]
133136 pub profile: Option<String>,
134137
src/main.rs +6 −1
@@ -27,7 +27,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
2727use std::sync::Arc;
2828use std::time::{Duration, Instant};
2929
30use clap::Parser;
30use clap::{CommandFactory, Parser};
3131use matrix_sdk::ruma::api::error::ErrorKind;
3232use matrix_sdk::ruma::OwnedUserId;
3333use matrix_sdk_crypto::encrypt_room_key_export;
@@ -1133,6 +1133,11 @@ fn main() {
11331133 // Parse command-line flags.
11341134 let iamb = Iamb::parse();
11351135
1136 if let Some(shell) = iamb.completions {
1137 clap_complete::generate(shell, &mut Iamb::command(), "iamb", &mut std::io::stdout());
1138 return;
1139 }
1140
11361141 // Load configuration and set up the Matrix SDK.
11371142 let settings = ApplicationSettings::load(iamb).unwrap_or_else(print_exit);
11381143