Feat/completion (#240)

* feat: add OpenRouter usage examples

* feat: add HTPS headers

* feat: add shell completion generation via clap_complete

* feat: add shell completion generation via clap_complete

* feat: add shell completion generation via clap_complete

* Refactor completion: use clap_complete::Shell directly, improve tests, remove tracing duplication, fix .env.example and Cargo.toml

* fix: rename init_cli_logging to init_cli_tracing (sync with main)

---------

Co-authored-by: BroccoliFin <[email protected]>
Co-authored-by: firat.sertgoz <[email protected]>
This commit is contained in:
DevBroco
2026-02-22 19:08:43 +00:00
committed by GitHub
co-authored by BroccoliFin firat.sertgoz
parent b8901baafd
commit 7f68207f1e
9 changed files with 5953 additions and 211 deletions
+39
View File
@@ -0,0 +1,39 @@
use clap::{CommandFactory, Parser};
use clap_complete::{Shell, generate};
use std::io;
/// Generate shell completion scripts for ironclaw
#[derive(Parser, Debug)]
pub struct Completion {
/// The shell to generate completions for
#[arg(value_enum, long)]
pub shell: Shell,
}
impl Completion {
pub fn run(&self) -> anyhow::Result<()> {
let mut cmd = crate::cli::Cli::command();
let bin_name = cmd.get_name().to_string();
// Generated and output script to stdout
generate(self.shell, &mut cmd, bin_name, &mut io::stdout());
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
use clap::CommandFactory;
#[test]
fn test_run_generates_output() {
let completion = Completion { shell: Shell::Zsh };
let mut cmd = crate::cli::Cli::command();
let bin_name = cmd.get_name().to_string();
let mut buf = Vec::new();
generate(completion.shell, &mut cmd, bin_name, &mut buf);
assert!(!buf.is_empty(), "generate() should produce output");
}
}