feat: install tab completion for bash, zsh, and fish (#16)
`completions install` generates the script from the same clap definition the binary parses with, so it cannot drift from `--help`, and writes it where each shell already looks. fish scans its own completions directory unprompted; bash and zsh get one marked `source` line appended to their rc file, because nothing puts a per-user directory on their search path by default. `completions uninstall` takes back exactly those lines and leaves the rest of the file alone.
This commit is contained in:
@@ -445,6 +445,28 @@ impl Record for SkillRecord {
|
||||
}
|
||||
}
|
||||
|
||||
/// What happened to one shell's completion script.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
pub struct CompletionRecord {
|
||||
/// `bash`, `zsh`, or `fish`.
|
||||
pub shell: String,
|
||||
pub path: String,
|
||||
/// `installed` (written), `unchanged` (already identical), `removed`, or
|
||||
/// `absent`.
|
||||
pub action: String,
|
||||
}
|
||||
|
||||
impl Record for CompletionRecord {
|
||||
fn text(&self) -> String {
|
||||
format!(
|
||||
"{}\t{}\t{}",
|
||||
sanitize(&self.action),
|
||||
sanitize(&self.shell),
|
||||
sanitize(&self.path)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// The result of probing automatic port mapping.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
pub struct PortmapRecord {
|
||||
|
||||
Reference in New Issue
Block a user