[Feature]: Generate shell completion scripts
Self-hosted secrets manager that keeps .env secrets from AI agents
Brought to you by:
dopbase
Originally created by: thomijasir
Originally owned by: thomijasir
Generate completion scripts for supported shells from the Dopbase command definition.
The CLI has command help but does not provide shell completion output.
The command tree now includes server, client, project, environment, secret, token, backup, and administration operations. Completion reduces typing mistakes and makes flags easier to discover.
dopbase completion bashdopbase completion zshdopbase completion fishdopbase completion powershelldopbase completion elvish--json is rejected because stdout is reserved for the script.app/tests/cli/.Add installation examples for each supported shell without modifying user profile files automatically.
Add the completion library that matches the current Clap version.
Originally posted by: rudratoshs
Hi @thomijasir — I'd be glad to take this one off your plate if outside PRs are welcome. I noticed most issues here are self-assigned, so I wanted to check before opening anything rather than surprise you with a PR you'd have to redirect.
Here's exactly how I'd implement it, to match the spec above and keep the surface minimal:
Approach
clap_complete(tracking the current clap 4 line) as the only new dependency.Completion { shell: clap_complete::Shell }variant toCommand.clap_complete::Shellis preciselybash/zsh/fish/powershell/elvish— the five listed — so an unsupported value is rejected by the parser itself with a non-zero exit, satisfying that criterion without custom validation.clap_complete::generate(shell, &mut Cli::command(), "dopbase", &mut io::stdout()), sourced from the derived command tree so new commands and flags appear automatically.--json completion …with a clear stderr message and non-zero exit, since stdout is reserved for the script.after_helpon the subcommand documents how to load each shell's output (e.g.source <(dopbase completion bash)) without editing any profile files.Tests (under
app/tests/cli/)completion <shell>parses for each supported shell; an unknown shell errors.secret get), and a global flag (--json/--server).--json completion bashis rejected with the reserved-stdout error.That keeps it to one dependency, one subcommand, and no new resolution rules — and leaves resource-aware completion (#25) to sit cleanly on top via a hidden entry point later.
Want me to open the PR on this, or would you rather keep it? Happy either way.
Originally posted by: thomijasir
Thanks for your input, @rudratoshs! This feature isn’t a priority right now, i’d like to focus on the core functionality and keep the CLI simple (trying to simplify
dopbase <command>).If you’d like to contribute, let’s start with something small. currently the app doesn't have a restart command yet, so adding
dopbase server restartwould be a great place to start.Thanks