diff --git a/CHANGELOG.md b/CHANGELOG.md index b8246602..ff66dde9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ## [Unreleased] - ReleaseDate +### Added + +- Add `slumber completions` subcommand + - Right now only static completions are available (e.g. subcommands). In the future I am to add dynamic completions based on your collection file (e.g. recipe and profile IDs) + ## [2.1.0] - 2024-09-27 ### Added diff --git a/crates/cli/src/commands.rs b/crates/cli/src/commands.rs index a99a858c..6b0b82f6 100644 --- a/crates/cli/src/commands.rs +++ b/crates/cli/src/commands.rs @@ -1,5 +1,5 @@ pub mod collections; -pub mod complete; +pub mod completions; pub mod generate; pub mod history; pub mod import; diff --git a/crates/cli/src/commands/complete.rs b/crates/cli/src/commands/completions.rs similarity index 82% rename from crates/cli/src/commands/complete.rs rename to crates/cli/src/commands/completions.rs index e205971b..af32ac11 100644 --- a/crates/cli/src/commands/complete.rs +++ b/crates/cli/src/commands/completions.rs @@ -1,20 +1,18 @@ -use crate::{Args, GlobalArgs, Subcommand}; +use crate::{Args, GlobalArgs, Subcommand, COMMAND_NAME}; use anyhow::anyhow; use clap::{CommandFactory, Parser}; use clap_complete::Shell; use std::{io, process::ExitCode}; -const COMMAND_NAME: &str = "slumber"; - /// Generate shell completions #[derive(Clone, Debug, Parser)] -pub struct CompleteCommand { +pub struct CompletionsCommand { /// Shell type. Default to $SHELL #[clap(long)] shell: Option, } -impl Subcommand for CompleteCommand { +impl Subcommand for CompletionsCommand { async fn execute(self, _: GlobalArgs) -> anyhow::Result { let shell = self .shell diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 80ccbe89..fc6afbf9 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -11,18 +11,21 @@ mod commands; mod util; use crate::commands::{ - collections::CollectionsCommand, complete::CompleteCommand, + collections::CollectionsCommand, completions::CompletionsCommand, generate::GenerateCommand, history::HistoryCommand, import::ImportCommand, new::NewCommand, request::RequestCommand, show::ShowCommand, }; use clap::Parser; use std::{path::PathBuf, process::ExitCode}; +const COMMAND_NAME: &str = "slumber"; + #[derive(Debug, Parser)] #[clap( author, version, about, + name = COMMAND_NAME, long_about = "Configurable HTTP client with both TUI and CLI interfaces" )] pub struct Args { @@ -54,7 +57,7 @@ pub struct GlobalArgs { #[derive(Clone, Debug, clap::Subcommand)] pub enum CliCommand { Collections(CollectionsCommand), - Complete(CompleteCommand), + Completions(CompletionsCommand), Generate(GenerateCommand), History(HistoryCommand), Import(ImportCommand), @@ -68,7 +71,7 @@ impl CliCommand { pub async fn execute(self, global: GlobalArgs) -> anyhow::Result { match self { Self::Collections(command) => command.execute(global).await, - Self::Complete(command) => command.execute(global).await, + Self::Completions(command) => command.execute(global).await, Self::Generate(command) => command.execute(global).await, Self::History(command) => command.execute(global).await, Self::Import(command) => command.execute(global).await,