diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-16 10:22:55 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-16 10:22:55 +0200 |
commit | e635ee79a4ec0d30dca271cc269fee40150ea821 (patch) | |
tree | 291cafa6ef3c1ea7cfcc080f3936e07b7722816e | |
parent | build(.envrc): Remove outdated env variables (diff) | |
download | yt-e635ee79a4ec0d30dca271cc269fee40150ea821.zip |
feat(yt/cli): Add support for command line completions
-rw-r--r-- | crates/yt/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/yt/src/main.rs | 13 |
2 files changed, 12 insertions, 2 deletions
diff --git a/crates/yt/Cargo.toml b/crates/yt/Cargo.toml index 100eb29..7289a4c 100644 --- a/crates/yt/Cargo.toml +++ b/crates/yt/Cargo.toml @@ -29,6 +29,7 @@ blake3 = "1.8.2" chrono = { version = "0.4.41", features = ["now"] } chrono-humanize = "0.2.3" clap = { version = "4.5.40", features = ["derive"] } +clap_complete = { version = "4.5.54", features = ["unstable-dynamic"] } futures = "0.3.31" owo-colors = "4.2.1" regex = "1.11.1" diff --git a/crates/yt/src/main.rs b/crates/yt/src/main.rs index dd23d9f..b6a7d29 100644 --- a/crates/yt/src/main.rs +++ b/crates/yt/src/main.rs @@ -19,7 +19,7 @@ use anyhow::{Context, Result, bail}; use app::App; use bytes::Bytes; use cache::{invalidate, maintain}; -use clap::Parser; +use clap::{CommandFactory, Parser}; use cli::{CacheCommand, SelectCommand, SubscriptionCommand, VideosCommand}; use config::Config; use log::{error, info}; @@ -56,6 +56,8 @@ pub mod watch; // This is _the_ main function after all. It is not really good, but it sort of works. #[allow(clippy::too_many_lines)] async fn main() -> Result<()> { + clap_complete::CompleteEnv::with_factory(cli::CliArgs::command).complete(); + let args = cli::CliArgs::parse(); // The default verbosity is 1 (Warn) @@ -218,7 +220,14 @@ async fn main() -> Result<()> { current_progress += CHUNK_SIZE; } } else { - update::update(&app, max_backlog, subscriptions, total_number, current_progress).await?; + update::update( + &app, + max_backlog, + subscriptions, + total_number, + current_progress, + ) + .await?; } } Command::Subscriptions { cmd } => match cmd { |