Browse Source

fix: panic on completions (#1010)

* fix(#1006): panic on completions

as far as i can tell, this was broken by the clap upgrade (#991).

* fix: add smoke test for completions

* skip test on windows

* Create dull-bottles-try.md

---------

Co-authored-by: Gal Schlezinger <gal@spitfire.co.il>
remotes/origin/list-filter
Devin Christensen 2 years ago committed by GitHub
parent
commit
b185446cfa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      .changeset/dull-bottles-try.md
  2. 18
      src/commands/completions.rs

5
.changeset/dull-bottles-try.md

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
---
"fnm": patch
---
fix: panic on `fnm completions`

18
src/commands/completions.rs

@ -24,7 +24,8 @@ impl Command for Completions { @@ -24,7 +24,8 @@ impl Command for Completions {
.or_else(|| infer_shell().map(Into::into))
.ok_or(Error::CantInferShell)?;
let shell: ClapShell = shell.into();
let app = Cli::command();
let mut app = Cli::command();
app.build();
shell.generate(&app, &mut stdio);
Ok(())
}
@ -49,3 +50,18 @@ fn shells_as_string() -> String { @@ -49,3 +50,18 @@ fn shells_as_string() -> String {
.collect::<Vec<_>>()
.join("\n")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
#[cfg(not(windows))]
fn test_smoke() {
let config = FnmConfig::default();
Completions {
shell: Some(Shells::Bash),
}
.call(config);
}
}

Loading…
Cancel
Save