Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get current juliaup channel with juliaup self channel #1033

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bin/juliainstaller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ pub fn main() -> Result<()> {
run_command_config_modifypath(Some(install_choices.modifypath), true, &paths).unwrap();
}
run_command_config_symlinks(Some(install_choices.symlinks), true, &paths).unwrap();
run_command_selfchannel(args.juliaup_channel, &paths).unwrap();
run_command_selfchannel(Some(args.juliaup_channel), &paths).unwrap();

run_command_add(&args.default_channel, &paths)
.with_context(|| "Failed to run `run_command_add`.")?;
Expand Down
5 changes: 2 additions & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ pub enum SelfSubCmd {
/// Update the Julia versions database and juliaup itself
Update {},
#[cfg(feature = "selfupdate")]
#[command(arg_required_else_help = true)]
/// Configure the channel to use for juliaup updates.
/// Configure the channel to use for juliaup updates. Leave CHANNEL blank to see current channel.
Channel {
#[arg(value_enum)]
channel: JuliaupChannel,
channel: Option<JuliaupChannel>,
},
#[cfg(feature = "selfupdate")]
/// Uninstall this version of juliaup from the system
Expand Down
19 changes: 14 additions & 5 deletions src/command_selfchannel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Result;

#[cfg(feature = "selfupdate")]
pub fn run_command_selfchannel(
channel: crate::cli::JuliaupChannel,
channel: Option<crate::cli::JuliaupChannel>,
paths: &crate::global_paths::GlobalPaths,
) -> Result<()> {
use crate::config_file::{load_mut_config_db, save_config_db};
Expand All @@ -12,10 +12,19 @@ pub fn run_command_selfchannel(
let mut config_file = load_mut_config_db(paths)
.with_context(|| "`self update` command failed to load configuration data.")?;

config_file.self_data.juliaup_channel = Some(channel.to_lowercase().to_string());

save_config_db(&mut config_file)
.with_context(|| "`selfchannel` command failed to save configuration db.")?;
match channel {
Some(chan) => {
config_file.self_data.juliaup_channel = Some(chan.to_lowercase().to_string());
save_config_db(&mut config_file)?;
}
None => {
let channel_name = config_file
.self_data
.juliaup_channel
.expect("juliaup_channel should not be empty.");
println!("Your juliaup is currently on channel `{}`. Run `juliaup self channel -h` for help on how to set the juliaup channel.", channel_name);
}
}

Ok(())
}