mirror of
https://github.com/rustic-rs/rustic.git
synced 2025-10-26 11:18:51 +00:00
Merge pull request #536 from rustic-rs/fix-shell-completions
Fix shell completions
This commit is contained in:
commit
a834e12fef
@ -4,6 +4,7 @@ Breaking changes:
|
||||
|
||||
Bugs fixed:
|
||||
- Fixed compiliation on OpenBSD.
|
||||
- Fixed shell completions.
|
||||
|
||||
New features:
|
||||
- REST backend: Set User-Agent header
|
||||
|
||||
@ -46,7 +46,7 @@ pub struct LocalSourceOptions {
|
||||
ignore_devid: bool,
|
||||
|
||||
/// Glob pattern to exclude/include (can be specified multiple times)
|
||||
#[clap(long, short = 'g', help_heading = "EXCLUDE OPTIONS")]
|
||||
#[clap(long, help_heading = "EXCLUDE OPTIONS")]
|
||||
#[merge(strategy = merge::vec::overwrite_empty)]
|
||||
glob: Vec<String>,
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
use std::io::Write;
|
||||
|
||||
use clap::{CommandFactory, Parser, ValueEnum};
|
||||
use clap_complete::{generate, shells, Generator};
|
||||
|
||||
@ -16,18 +18,25 @@ pub(super) enum Variant {
|
||||
|
||||
pub(super) fn execute(opts: Opts) {
|
||||
match opts.sh {
|
||||
Variant::Bash => generate_completion(shells::Bash),
|
||||
Variant::Fish => generate_completion(shells::Fish),
|
||||
Variant::Zsh => generate_completion(shells::Zsh),
|
||||
Variant::Bash => generate_completion(shells::Bash, &mut std::io::stdout()),
|
||||
Variant::Fish => generate_completion(shells::Fish, &mut std::io::stdout()),
|
||||
Variant::Zsh => generate_completion(shells::Zsh, &mut std::io::stdout()),
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_completion<G: Generator>(shell: G) {
|
||||
fn generate_completion<G: Generator>(shell: G, buf: &mut dyn Write) {
|
||||
let mut command = super::Opts::command();
|
||||
generate(
|
||||
shell,
|
||||
&mut command,
|
||||
env!("CARGO_BIN_NAME"),
|
||||
&mut std::io::stdout(),
|
||||
);
|
||||
generate(shell, &mut command, env!("CARGO_BIN_NAME"), buf);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_completions() {
|
||||
generate_completion(shells::Bash, &mut std::io::sink());
|
||||
generate_completion(shells::Fish, &mut std::io::sink());
|
||||
generate_completion(shells::Zsh, &mut std::io::sink());
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ struct SnapOpts {
|
||||
dry_run: bool,
|
||||
|
||||
/// Also remove defect snapshots - WARNING: This can result in data loss!
|
||||
#[clap(long, short = 'n')]
|
||||
#[clap(long)]
|
||||
delete: bool,
|
||||
|
||||
/// Append this suffix to repaired directory or file name
|
||||
|
||||
@ -43,7 +43,7 @@ pub(super) struct Opts {
|
||||
numeric_id: bool,
|
||||
|
||||
/// Don't restore ownership (user/group)
|
||||
#[clap(long, conflicts_with = "numeric_id")]
|
||||
#[clap(long, conflicts_with = "numeric-id")]
|
||||
no_ownership: bool,
|
||||
|
||||
/// Warm up needed data pack files by only requesting them without processing
|
||||
|
||||
Loading…
Reference in New Issue
Block a user