Skip to content

Commit 1ea1da7

Browse files
committed
Support commandline completion
To enable, run: `source <(COMPLETE=bash cfsrun)`. Or packagers could use this to generate a bash completion script at build time. Signed-off-by: Alexander Larsson <alexl@redhat.com>
1 parent bf3c1dc commit 1ea1da7

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 29 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composefs-run/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ path = "src/main.rs"
1212
[dependencies]
1313
anyhow = { version = "1.0", default-features = false }
1414
clap = { version = "4.5", default-features = false, features = ["std", "help", "usage", "derive"] }
15+
clap_complete = { version = "4.5", default-features = false, features = ["unstable-dynamic"] }
1516
composefs = { workspace = true }
1617
composefs-fuse = { workspace = true }
1718
composefs-oci = { workspace = true }

composefs-run/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod userns;
1010
use std::path::PathBuf;
1111

1212
use anyhow::{Context, Result, ensure};
13-
use clap::Parser;
13+
use clap::{CommandFactory, Parser};
1414
use composefs::fsverity::{FsVerityHashValue, Sha256HashValue, Sha512HashValue};
1515
use composefs::repository::{Repository, read_repo_algorithm};
1616
use composefs_oci::OciDigest;
@@ -411,6 +411,8 @@ pub(crate) struct Cli {
411411
}
412412

413413
fn main() -> Result<()> {
414+
clap_complete::CompleteEnv::with_factory(Cli::command).complete();
415+
414416
match std::env::args().nth(1).as_deref() {
415417
Some("--internal-cleanup") => return run::cleanup(),
416418
Some("--internal-fuse-serve") => {

0 commit comments

Comments
 (0)