-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #1655
- Loading branch information
Showing
18 changed files
with
311 additions
and
57 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# `mise en` | ||
|
||
- **Usage**: `mise en [-s --shell <SHELL>] [DIR]` | ||
- **Source code**: [`src/cli/en.rs`](https://github.com/jdx/mise/blob/main/src/cli/en.rs) | ||
|
||
[experimental] starts a new shell with the mise environment built from the current configuration | ||
|
||
This is an alternative to `mise activate` that allows you to explicitly start a mise session. | ||
It will have the tools and environment variables in the configs loaded. | ||
Note that changing directories will not update the mise environment. | ||
|
||
## Arguments | ||
|
||
### `[DIR]` | ||
|
||
Directory to start the shell in | ||
|
||
**Default:** `.` | ||
|
||
## Flags | ||
|
||
### `-s --shell <SHELL>` | ||
|
||
Shell to start | ||
|
||
Defaults to $SHELL | ||
|
||
Examples: | ||
|
||
$ mise en . | ||
$ node -v | ||
v20.0.0 | ||
|
||
Skip loading bashrc: | ||
$ mise en -s "bash --norc" | ||
|
||
Skip loading zshrc: | ||
$ mise en -s "zsh -f" |
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 |
---|---|---|
|
@@ -56,6 +56,14 @@ Print directly to stdout/stderr instead of by line | |
Defaults to true if --jobs == 1 | ||
Configure with `task_output` config or `MISE_TASK_OUTPUT` env var | ||
|
||
### `-s --shell <SHELL>` | ||
|
||
Shell to use to run toml tasks | ||
|
||
Defaults to `sh -c -o errexit -o pipefail` on unix, and `cmd /c` on Windows | ||
Can also be set with the setting `MISE_UNIX_DEFAULT_INLINE_SHELL_ARGS` or `MISE_WINDOWS_DEFAULT_INLINE_SHELL_ARGS` | ||
Or it can be overridden with the `shell` property on a task. | ||
|
||
### `-t --tool... <TOOL@VERSION>` | ||
|
||
Tool(s) to run in addition to what is in mise.toml files e.g.: node@20 [email protected] | ||
|
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 |
---|---|---|
|
@@ -70,6 +70,14 @@ Print directly to stdout/stderr instead of by line | |
Defaults to true if --jobs == 1 | ||
Configure with `task_output` config or `MISE_TASK_OUTPUT` env var | ||
|
||
### `-s --shell <SHELL>` | ||
|
||
Shell to use to run toml tasks | ||
|
||
Defaults to `sh -c -o errexit -o pipefail` on unix, and `cmd /c` on Windows | ||
Can also be set with the setting `MISE_UNIX_DEFAULT_INLINE_SHELL_ARGS` or `MISE_WINDOWS_DEFAULT_INLINE_SHELL_ARGS` | ||
Or it can be overridden with the `shell` property on a task. | ||
|
||
### `-t --tool... <TOOL@VERSION>` | ||
|
||
Tool(s) to run in addition to what is in mise.toml files e.g.: node@20 [email protected] | ||
|
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 |
---|---|---|
|
@@ -34,6 +34,9 @@ flag "-p --prefix" hide=true | |
flag "-P --profile" help="Set the profile (environment)" hide=true global=true { | ||
arg "<PROFILE>" | ||
} | ||
flag "-s --shell" hide=true { | ||
arg "<SHELL>" | ||
} | ||
flag "-t --tool" help="Tool(s) to run in addition to what is in mise.toml files e.g.: node@20 [email protected]" var=true hide=true { | ||
arg "<TOOL@VERSION>" | ||
} | ||
|
@@ -343,6 +346,30 @@ cmd "doctor" help="Check mise installation for possible problems" { | |
[WARN] plugin node is not installed | ||
" | ||
} | ||
cmd "en" help="[experimental] starts a new shell with the mise environment built from the current configuration" { | ||
long_help r"[experimental] starts a new shell with the mise environment built from the current configuration | ||
|
||
This is an alternative to `mise activate` that allows you to explicitly start a mise session. | ||
It will have the tools and environment variables in the configs loaded. | ||
Note that changing directories will not update the mise environment." | ||
after_long_help r#"Examples: | ||
|
||
$ mise en . | ||
$ node -v | ||
v20.0.0 | ||
|
||
Skip loading bashrc: | ||
$ mise en -s "bash --norc" | ||
|
||
Skip loading zshrc: | ||
$ mise en -s "zsh -f" | ||
"# | ||
flag "-s --shell" help="Shell to start" { | ||
long_help "Shell to start\n\nDefaults to $SHELL" | ||
arg "<SHELL>" | ||
} | ||
arg "[DIR]" help="Directory to start the shell in" default="." | ||
} | ||
cmd "env" help="Exports env vars to activate mise a single time" { | ||
alias "e" | ||
long_help r"Exports env vars to activate mise a single time | ||
|
@@ -958,6 +985,10 @@ The name of the script will be the name of the tasks. | |
flag "-f --force" help="Force the tasks to run even if outputs are up to date" | ||
flag "-p --prefix" help="Print stdout/stderr by line, prefixed with the tasks's label\nDefaults to true if --jobs > 1\nConfigure with `task_output` config or `MISE_TASK_OUTPUT` env var" | ||
flag "-i --interleave" help="Print directly to stdout/stderr instead of by line\nDefaults to true if --jobs == 1\nConfigure with `task_output` config or `MISE_TASK_OUTPUT` env var" | ||
flag "-s --shell" help="Shell to use to run toml tasks" { | ||
long_help "Shell to use to run toml tasks\n\nDefaults to `sh -c -o errexit -o pipefail` on unix, and `cmd /c` on Windows\nCan also be set with the setting `MISE_UNIX_DEFAULT_INLINE_SHELL_ARGS` or `MISE_WINDOWS_DEFAULT_INLINE_SHELL_ARGS`\nOr it can be overridden with the `shell` property on a task." | ||
arg "<SHELL>" | ||
} | ||
flag "-t --tool" help="Tool(s) to run in addition to what is in mise.toml files e.g.: node@20 [email protected]" var=true { | ||
arg "<TOOL@VERSION>" | ||
} | ||
|
@@ -1321,6 +1352,10 @@ The name of the script will be the name of the tasks. | |
flag "-f --force" help="Force the tasks to run even if outputs are up to date" | ||
flag "-p --prefix" help="Print stdout/stderr by line, prefixed with the tasks's label\nDefaults to true if --jobs > 1\nConfigure with `task_output` config or `MISE_TASK_OUTPUT` env var" | ||
flag "-i --interleave" help="Print directly to stdout/stderr instead of by line\nDefaults to true if --jobs == 1\nConfigure with `task_output` config or `MISE_TASK_OUTPUT` env var" | ||
flag "-s --shell" help="Shell to use to run toml tasks" { | ||
long_help "Shell to use to run toml tasks\n\nDefaults to `sh -c -o errexit -o pipefail` on unix, and `cmd /c` on Windows\nCan also be set with the setting `MISE_UNIX_DEFAULT_INLINE_SHELL_ARGS` or `MISE_WINDOWS_DEFAULT_INLINE_SHELL_ARGS`\nOr it can be overridden with the `shell` property on a task." | ||
arg "<SHELL>" | ||
} | ||
flag "-t --tool" help="Tool(s) to run in addition to what is in mise.toml files e.g.: node@20 [email protected]" var=true { | ||
arg "<TOOL@VERSION>" | ||
} | ||
|
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,59 @@ | ||
use crate::cli::exec::Exec; | ||
use crate::config::Settings; | ||
use std::path::PathBuf; | ||
|
||
use crate::env; | ||
|
||
/// [experimental] starts a new shell with the mise environment built from the current configuration | ||
/// | ||
/// This is an alternative to `mise activate` that allows you to explicitly start a mise session. | ||
/// It will have the tools and environment variables in the configs loaded. | ||
/// Note that changing directories will not update the mise environment. | ||
#[derive(Debug, clap::Args)] | ||
#[clap(verbatim_doc_comment, after_long_help = AFTER_LONG_HELP)] | ||
pub struct En { | ||
/// Directory to start the shell in | ||
#[clap(default_value = ".", verbatim_doc_comment, value_hint = clap::ValueHint::DirPath)] | ||
pub dir: PathBuf, | ||
|
||
/// Shell to start | ||
/// | ||
/// Defaults to $SHELL | ||
#[clap(verbatim_doc_comment, long, short = 's', env = "MISE_SHELL")] | ||
pub shell: Option<String>, | ||
} | ||
|
||
impl En { | ||
pub fn run(self) -> eyre::Result<()> { | ||
let settings = Settings::get(); | ||
settings.ensure_experimental("en")?; | ||
|
||
env::set_current_dir(&self.dir)?; | ||
let shell = self.shell.unwrap_or((*env::SHELL).clone()); | ||
let command = shell_words::split(&shell).map_err(|e| eyre::eyre!(e))?; | ||
|
||
Exec { | ||
tool: vec![], | ||
raw: false, | ||
jobs: None, | ||
c: None, | ||
command: Some(command), | ||
} | ||
.run() | ||
} | ||
} | ||
|
||
static AFTER_LONG_HELP: &str = color_print::cstr!( | ||
r#"<bold><underline>Examples:</underline></bold> | ||
$ <bold>mise en .</bold> | ||
$ <bold>node -v</bold> | ||
v20.0.0 | ||
Skip loading bashrc: | ||
$ <bold>mise en -s "bash --norc"</bold> | ||
Skip loading zshrc: | ||
$ <bold>mise en -s "zsh -f"</bold> | ||
"# | ||
); |
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 |
---|---|---|
|
@@ -20,6 +20,7 @@ mod current; | |
mod deactivate; | ||
mod direnv; | ||
mod doctor; | ||
mod en; | ||
mod env; | ||
pub mod exec; | ||
mod external; | ||
|
@@ -112,6 +113,8 @@ pub struct Cli { | |
/// Set the profile (environment) | ||
#[clap(short = 'P', long, global = true, hide = true)] | ||
pub profile: Option<String>, | ||
#[clap(long, short, hide = true)] | ||
pub shell: Option<String>, | ||
/// Tool(s) to run in addition to what is in mise.toml files | ||
/// e.g.: node@20 [email protected] | ||
#[clap(short, long, hide = true, value_name = "TOOL@VERSION")] | ||
|
@@ -159,6 +162,7 @@ pub enum Commands { | |
Deactivate(deactivate::Deactivate), | ||
Direnv(direnv::Direnv), | ||
Doctor(doctor::Doctor), | ||
En(en::En), | ||
Env(env::Env), | ||
Exec(exec::Exec), | ||
Generate(generate::Generate), | ||
|
@@ -219,6 +223,7 @@ impl Commands { | |
Self::Deactivate(cmd) => cmd.run(), | ||
Self::Direnv(cmd) => cmd.run(), | ||
Self::Doctor(cmd) => cmd.run(), | ||
Self::En(cmd) => cmd.run(), | ||
Self::Env(cmd) => cmd.run(), | ||
Self::Exec(cmd) => cmd.run(), | ||
Self::Generate(cmd) => cmd.run(), | ||
|
@@ -325,6 +330,7 @@ impl Cli { | |
no_timings: self.no_timings, | ||
output: run::TaskOutput::Prefix, | ||
prefix: self.prefix, | ||
shell: self.shell, | ||
quiet: self.quiet, | ||
raw: self.raw, | ||
timings: self.timings, | ||
|
Oops, something went wrong.