Skip to content
Draft
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
747 changes: 419 additions & 328 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ codegen-units = 1

[dependencies]
clap = { version = "4.5", features = ["derive"] }
clap_complete = "4.5"
clap_complete = { version = "4.5", features = ["unstable-dynamic"] }
dirs = "6.0.0"
dunce = "1.0"
serde = { version = "1.0", features = ["derive"] }
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ Here are some of the things you can do with `juliaup`:
- `juliaup override set --path foo/bar lts` sets a directory override for the path `foo/bar` to the `lts` channel.
- `juliaup override unset --path foo/bar` removes a directory override for the path `foo/bar`.
- `juliaup override unset --nonexistent` removes all directory overrides for paths that no longer exist.
- `juliaup completions bash > ~/.local/share/bash-completion/completions/juliaup` generates Bash completions for `juliaup` and saves them to a file. To use them, simply source this file in your `~/.bashrc`. Other supported shells are `zsh`, `fish`, `elvish` and `powershell`.
- `juliaup` shows you what other commands are available.

The available system provided channels are:
Expand Down Expand Up @@ -169,6 +168,19 @@ the `JULIAUP_DEPOT_PATH` environment variable. Caution: Previous versions of Jul
Juliaup by default downloads julia binary tarballs from the official server "https://julialang-s3.julialang.org".
If requested, the environment variable `JULIAUP_SERVER` can be used to tell Juliaup to use a third-party mirror server.

## Shell completions

To generate shell completions, load `COMPLETE=$SHELL juliaup` at shell launch. For example, with bash, it could look like `source <(COMPLETE=bash juliaup)`.

For more specific information on adding completions to your shell, see https://docs.rs/clap_complete/latest/clap_complete/env/index.html

Note: MacOS ships with an ancient version of bash that does not support process substitution. To work around this, you can create a temporary file and `source` that instead like:

```bash
COMPLETE=bash juliaup > /tmp/juliaup_completion.sh
source /tmp/juliaup_completion.sh
```

## Development guides

For juliaup developers, information on how to build juliaup locally, update julia versions, and release updates
Expand Down
7 changes: 4 additions & 3 deletions src/bin/juliaup.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use anyhow::{Context, Result};
use clap::Parser;
use clap::{CommandFactory, Parser};
use clap_complete::CompleteEnv;
use juliaup::cli::{ConfigSubCmd, Juliaup, OverrideSubCmd, SelfSubCmd};
use juliaup::command_api::run_command_api;
use juliaup::command_completions::run_command_completions;
#[cfg(not(windows))]
use juliaup::command_config_symlinks::run_command_config_symlinks;
use juliaup::command_config_versionsdbupdate::run_command_config_versionsdbupdate;
Expand Down Expand Up @@ -37,6 +37,8 @@ use juliaup::command_selfuninstall::run_command_selfuninstall_unavailable;
use log::info;

fn main() -> Result<()> {
CompleteEnv::with_factory(|| Juliaup::command()).complete();

human_panic::setup_panic!(
human_panic::Metadata::new("Juliaup", env!("CARGO_PKG_VERSION"))
.support("https://github.com/JuliaLang/juliaup")
Expand Down Expand Up @@ -148,6 +150,5 @@ fn main() -> Result<()> {
#[cfg(not(feature = "selfupdate"))]
SelfSubCmd::Uninstall {} => run_command_selfuninstall_unavailable(),
},
Juliaup::Completions { shell } => run_command_completions(shell),
}
}
4 changes: 1 addition & 3 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::{Parser, ValueEnum};

#[derive(Parser)]
#[clap(name = "Juliaup", version)]
#[clap(name = "juliaup", version)]
#[command(
after_help = "To launch a specific Julia version, use `julia +{channel}` e.g. `julia +1.6`.
Entering just `julia` uses the default channel set via `juliaup default`."
Expand Down Expand Up @@ -50,8 +50,6 @@ pub enum Juliaup {
Info {},
#[clap(subcommand, name = "self")]
SelfSubCmd(SelfSubCmd),
/// Generate tab-completion scripts for your shell
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
16 changes: 0 additions & 16 deletions src/command_completions.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use anyhow::Context;
pub mod cli;
pub mod command_add;
pub mod command_api;
pub mod command_completions;
pub mod command_config_backgroundselfupdate;
pub mod command_config_modifypath;
pub mod command_config_startupselfupdate;
Expand Down
4 changes: 2 additions & 2 deletions src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ pub fn install_from_url(
let server_etag = match download_result {
Ok(last_updated) => last_updated,
Err(e) => {
std::fs::remove_dir_all(temp_dir.into_path())?;
std::fs::remove_dir_all(temp_dir.keep())?;
bail!("Failed to download and extract pr or nightly: {}", e);
}
};
Expand Down Expand Up @@ -619,7 +619,7 @@ pub fn install_from_url(
if target_path.exists() {
std::fs::remove_dir_all(&target_path)?;
}
std::fs::rename(temp_dir.into_path(), &target_path)?;
std::fs::rename(temp_dir.keep(), &target_path)?;

Ok(JuliaupConfigChannel::DirectDownloadChannel {
path: path.to_string_lossy().into_owned(),
Expand Down
Loading