Skip to content

Commit

Permalink
Add a secret --installation-path argument to gel cli install (#1499)
Browse files Browse the repository at this point in the history
We want to start supporting cli upgrade when the CLI is installed in
non-standard locations.

Part of the complication here is that the way this works is that the
old CLI downloads the new CLI and then asks the *new CLI* to install
itself (with the `--upgrade`) flag.

So we need a way to communicate to it where it should do this
installation to `gel cli install`, so we add a hidden
`--installation-path` flag to cli install in order to support this.

(Another approach that I think might work would be to make `gel
install --upgrade` always use the directory of the current
executable. The advantage there is that no new flag needs to be added
that could tangle up the communication, but the disadvantage is that
it is changing existing behavior in possibly dangerous ways.)

My plan is to land this and make sure it is *released on all
channels*, and then I can go update `gel cli upgrade` to use it,
and be able to test it end-to-end as I do so.
  • Loading branch information
msullivan authored Feb 24, 2025
1 parent 369f0d1 commit bdb161a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cli/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ pub struct Command {
/// Installation is run from `self upgrade` command
#[arg(long, hide = true)]
pub upgrade: bool,

#[arg(long, hide=true, value_hint=clap::ValueHint::AnyPath)]
pub installation_path: Option<PathBuf>,
}

pub struct Settings {
Expand Down Expand Up @@ -114,7 +117,10 @@ fn _run(cmd: &Command) -> anyhow::Result<()> {
_ => {}
}
}
let installation_path = binary_path()?.parent().unwrap().to_owned();
let installation_path = match &cmd.installation_path {
Some(path) => path.clone(),
None => binary_path()?.parent().unwrap().to_owned(),
};
let mut settings = Settings {
rc_files: get_rc_files()?,
system: false,
Expand Down

0 comments on commit bdb161a

Please sign in to comment.