use crate::cli::exec::Exec;
use std::path::PathBuf;
use crate::env;
#[derive(Debug, usage_rs::Args)]
#[usage(verbatim_doc_comment, after_long_help = AFTER_LONG_HELP)]
pub(crate) struct En {
#[usage(default = ".", verbatim_doc_comment, value_hint = usage_rs::ValueHint::DirPath)]
pub dir: PathBuf,
#[usage(verbatim_doc_comment, long, short = 's')]
pub shell: Option<String>,
}
impl En {
pub(crate) async fn run(self) -> eyre::Result<()> {
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),
no_deps: false,
fresh_env: false,
deny_all: false,
deny_read: false,
deny_write: false,
deny_net: false,
deny_env: false,
allow_read: vec![],
allow_write: vec![],
allow_net: vec![],
allow_env: vec![],
}
.run()
.await
}
}
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>
"#
);