-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes jdx#1039
- Loading branch information
Showing
11 changed files
with
144 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# `mise install-into` | ||
|
||
- **Usage**: `mise install-into <TOOL@VERSION> <PATH>` | ||
- **Source code**: [`src/cli/install-into.rs`](https://github.com/jdx/mise/blob/main/src/cli/install-into.rs) | ||
|
||
Install a tool version to a specific path | ||
|
||
Used for building a tool to a directory for use outside of mise | ||
|
||
## Arguments | ||
|
||
### `<TOOL@VERSION>` | ||
|
||
Tool to install e.g.: node@20 | ||
|
||
### `<PATH>` | ||
|
||
Path to install the tool into | ||
|
||
Examples: | ||
|
||
``` | ||
# install node@20.0.0 into ./mynode | ||
$ mise install-into node@20.0.0 ./mynode && ./mynode/bin/node -v | ||
20.0.0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
assert "mise install-into node@22.0.0 ./mynode" | ||
assert "./mynode/bin/node -v" "v22.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use crate::cli::args::ToolArg; | ||
use crate::config::Config; | ||
use crate::install_context::InstallContext; | ||
use crate::toolset::ToolsetBuilder; | ||
use crate::ui::multi_progress_report::MultiProgressReport; | ||
use clap::ValueHint; | ||
use eyre::{eyre, Result}; | ||
use std::path::PathBuf; | ||
|
||
/// Install a tool version to a specific path | ||
/// | ||
/// Used for building a tool to a directory for use outside of mise | ||
#[derive(Debug, clap::Args)] | ||
#[clap(verbatim_doc_comment, after_long_help = AFTER_LONG_HELP)] | ||
pub struct InstallInto { | ||
/// Tool to install | ||
/// e.g.: node@20 | ||
#[clap(value_name = "TOOL@VERSION")] | ||
tool: ToolArg, | ||
|
||
/// Path to install the tool into | ||
#[clap(value_hint = ValueHint::DirPath)] | ||
path: PathBuf, | ||
} | ||
|
||
impl InstallInto { | ||
pub fn run(self) -> Result<()> { | ||
let config = Config::get(); | ||
let ts = ToolsetBuilder::new() | ||
.with_args(&[self.tool.clone()]) | ||
.build(&config)?; | ||
let mut tv = ts | ||
.versions | ||
.get(&self.tool.ba) | ||
.ok_or_else(|| eyre!("Tool not found"))? | ||
.versions | ||
.first() | ||
.unwrap() | ||
.clone(); | ||
let backend = tv.backend()?; | ||
let mpr = MultiProgressReport::get(); | ||
let install_ctx = InstallContext { | ||
ts: &ts, | ||
pr: mpr.add(&tv.style()), | ||
force: true, | ||
}; | ||
tv.install_path = Some(self.path.clone()); | ||
backend.install_version(install_ctx, tv)?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
static AFTER_LONG_HELP: &str = color_print::cstr!( | ||
r#"<bold><underline>Examples:</underline></bold> | ||
# install node@20.0.0 into ./mynode | ||
$ <bold>mise install-into node@20.0.0 ./mynode && ./mynode/bin/node -v</bold> | ||
20.0.0 | ||
"# | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters