Skip to content

Commit

Permalink
Merge branch 'main' into fix-installer-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Gambitier authored Jul 3, 2024
2 parents dc7266a + 8d632b2 commit 130d989
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/bin/juliaup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ fn main() -> Result<()> {
#[cfg(not(feature = "selfupdate"))]
SelfSubCmd::Uninstall {} => run_command_selfuninstall_unavailable(),
},
Juliaup::Completions { shell } => run_command_completions(&shell),
Juliaup::Completions { shell } => run_command_completions(shell),
}
}
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub enum Juliaup {
#[clap(subcommand, name = "self")]
SelfSubCmd(SelfSubCmd),
/// Generate tab-completion scripts for your shell
Completions { shell: String },
Completions { shell: clap_complete::Shell },
// This is used for the cron jobs that we create. By using this UUID for the command
// We can identify the cron jobs that were created by juliaup for uninstall purposes
#[cfg(feature = "selfupdate")]
Expand Down
20 changes: 7 additions & 13 deletions src/command_completions.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
use crate::cli;
use anyhow::bail;
use anyhow::Result;
use clap::CommandFactory;
use clap_complete::Shell;
use cli::Juliaup;
use std::io;
use std::str::FromStr;

pub fn run_command_completions(shell: &str) -> Result<()> {
if let Ok(shell) = Shell::from_str(shell) {
clap_complete::generate(
shell,
&mut Juliaup::command(),
"juliaup",
&mut io::stdout().lock(),
);
} else {
bail!("'{}' is not a supported shell.", shell)
}
pub fn run_command_completions(shell: Shell) -> Result<()> {
clap_complete::generate(
shell,
&mut Juliaup::command(),
"juliaup",
&mut io::stdout().lock(),
);
Ok(())
}

0 comments on commit 130d989

Please sign in to comment.