Skip to content

Commit

Permalink
fix: panic on completions (#1010)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
quixoten and Schniz committed Aug 15, 2023
1 parent a4432e6 commit b185446
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/dull-bottles-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fnm": patch
---

fix: panic on `fnm completions`
18 changes: 17 additions & 1 deletion src/commands/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand All @@ -49,3 +50,18 @@ fn shells_as_string() -> String {
.collect::<Vec<_>>()
.join("\n")
}

#[cfg(test)]
mod tests {
use super::*;

Check warning on line 56 in src/commands/completions.rs

View workflow job for this annotation

GitHub Actions / unit_tests (windows-latest)

unused import: `super::*`

#[test]
#[cfg(not(windows))]
fn test_smoke() {
let config = FnmConfig::default();
Completions {
shell: Some(Shells::Bash),
}
.call(config);
}
}

0 comments on commit b185446

Please sign in to comment.