Skip to content
Merged
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
19 changes: 17 additions & 2 deletions e2e/tasks/test_task_help
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
#!/usr/bin/env bash

cat <<EOF >mise.toml
[tasks.a]
[tasks.atask]
run = 'echo {{arg(name="myarg")}}'
[tasks.npm]
run = 'echo npm'
EOF

assert "mise run a --help 2>&1 || true" "Usage: a <myarg>
assert "mise run atask --help 2>&1 || true" "Usage: atask <myarg>

Arguments:
<myarg>"

assert_contains "mise --help 2>&1 || true" "Usage: mise [OPTIONS] [TASK] [COMMAND]"
assert_contains "mise install --help 2>&1 || true" "Usage: mise install [OPTIONS] [TOOL@VERSION]..."
assert_contains "mise run --help 2>&1 || true" "Usage: run [OPTIONS] [TASK] [ARGS]..."
assert_contains "mise atask -- --help 2>&1 || true" "Usage: atask <myarg>"
assert "mise run -q npm --help 2>&1 || true" "npm --help"
assert "mise -q npm -- --help 2>&1 || true" "npm --help"
assert "mise atask -q -- -- --help 2>&1 || true" "--help"
assert_contains "mise run atask -q -- --help 2>&1 || true" "Usage: atask <myarg>"
assert_contains "mise run atask -q -- foo --help 2>&1 || true" "Usage: atask <myarg>"
assert_contains "mise run atask -q foo --help 2>&1 || true" "Usage: atask <myarg>"
assert_contains "mise atask -q -- foo --help 2>&1 || true" "Usage: atask <myarg>"
assert_contains "mise atask -q foo --help 2>&1 || true" "Usage: atask <myarg>"
2 changes: 0 additions & 2 deletions e2e/tasks/test_task_options
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ tasks.mytask = 'echo {{option(name="foo")}}'
EOF

assert "mise run mytask --foo bar" "bar"
assert "mise run -- mytask --foo bar" "bar"
assert "mise run mytask -- --foo bar" "bar"
assert "mise mytask --foo bar" "bar"
assert "mise -- mytask --foo bar" "bar"
assert "mise mytask -- --foo bar" "bar"
2 changes: 1 addition & 1 deletion man/man1/mise.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.SH NAME
mise \- The front\-end to your dev env
.SH SYNOPSIS
\fBmise\fR [\fB\-C\fR|\fB\-\-cd\fR] [\fB\-E\fR|\fB\-\-env\fR] [\fB\-j\fR|\fB\-\-jobs\fR] [\fB\-\-output\fR] [\fB\-\-raw\fR] [\fB\-\-no\-config\fR] [\fB\-y\fR|\fB\-\-yes\fR] [\fB\-q\fR|\fB\-\-quiet\fR] [\fB\-\-silent\fR] [\fB\-v\fR|\fB\-\-verbose\fR]... [\fB\-h\fR|\fB\-\-help\fR] [\fITASK\fR] [\fITASK_ARGS\fR] [\fIsubcommands\fR]
\fBmise\fR [\fB\-C\fR|\fB\-\-cd\fR] [\fB\-E\fR|\fB\-\-env\fR] [\fB\-j\fR|\fB\-\-jobs\fR] [\fB\-\-output\fR] [\fB\-\-raw\fR] [\fB\-\-no\-config\fR] [\fB\-y\fR|\fB\-\-yes\fR] [\fB\-q\fR|\fB\-\-quiet\fR] [\fB\-\-silent\fR] [\fB\-v\fR|\fB\-\-verbose\fR]... [\fB\-h\fR|\fB\-\-help\fR] [\fITASK\fR] [\fITASK_ARGS\fR] [\fITASK_ARGS_LAST\fR] [\fIsubcommands\fR]
.SH DESCRIPTION
.PP
mise is a tool for managing runtime versions. https://github.com/jdx/mise
Expand Down
6 changes: 4 additions & 2 deletions mise.usage.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ flag "--silent" help="Suppress all task output and mise non-error messages" glob
flag "--trace" help="Sets log level to trace" hide=true global=true
flag "-v --verbose" help="Show extra output (use -vv for even more)" var=true global=true count=true
arg "[TASK]" help="Task to run" help_long="Task to run.\n\nShorthand for `mise task run <TASK>`." required=false
arg "[TASK_ARGS]..." help="Task arguments" required=false double_dash="automatic" var=true hide=true
arg "[TASK_ARGS]..." help="Task arguments" required=false var=true hide=true
arg "[-- TASK_ARGS_LAST]..." required=false var=true hide=true
cmd "activate" help="Initializes mise in the current shell session" {
long_help r#"Initializes mise in the current shell session

Expand Down Expand Up @@ -1533,7 +1534,8 @@ The name of the script will be the name of the tasks.
arg "<OUTPUT>"
}
arg "[TASK]" help="Tasks to run\nCan specify multiple tasks by separating with `:::`\ne.g.: mise run task1 arg1 arg2 ::: task2 arg1 arg2" required=false default="default"
arg "[ARGS]..." help="Arguments to pass to the tasks. Use \":::\" to separate tasks" required=false double_dash="automatic" var=true
arg "[ARGS]..." help="Arguments to pass to the tasks. Use \":::\" to separate tasks" required=false var=true
arg "[-- ARGS_LAST]..." help="Arguments to pass to the tasks. Use \":::\" to separate tasks" required=false var=true hide=true
mount run="mise tasks --usage"
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ pub struct Cli {
#[clap(name = "TASK", long_help = LONG_TASK_ABOUT)]
pub task: Option<String>,
/// Task arguments
#[clap(trailing_var_arg = true, allow_hyphen_values = true, hide = true)]
#[clap(allow_hyphen_values = true, hide = true)]
pub task_args: Option<Vec<String>>,
#[clap(last = true, hide = true)]
pub task_args_last: Vec<String>,
/// Change directory before running command
#[clap(short='C', long, global=true, value_name="DIR", value_hint=clap::ValueHint::DirPath)]
pub cd: Option<PathBuf>,
Expand Down Expand Up @@ -367,6 +369,7 @@ impl Cli {
return Ok(Commands::Run(run::Run {
task,
args: self.task_args.unwrap_or_default(),
args_last: self.task_args_last,
cd: self.cd,
continue_on_error: self.continue_on_error,
dry_run: self.dry_run,
Expand All @@ -390,7 +393,11 @@ impl Cli {
external::execute(
&task.into(),
cmd.clone(),
self.task_args.unwrap_or_default(),
self.task_args
.unwrap_or_default()
.into_iter()
.chain(self.task_args_last)
.collect(),
)?;
exit(0);
}
Expand Down
12 changes: 8 additions & 4 deletions src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ use xx::regex;
/// EOF
/// $ mise run build
#[derive(Debug, clap::Args)]
#[clap(visible_alias = "r", verbatim_doc_comment, disable_help_flag = true, after_long_help = AFTER_LONG_HELP
)]
#[clap(visible_alias = "r", verbatim_doc_comment, disable_help_flag = true, after_long_help = AFTER_LONG_HELP)]
pub struct Run {
/// Tasks to run
/// Can specify multiple tasks by separating with `:::`
Expand All @@ -73,9 +72,13 @@ pub struct Run {
pub task: String,

/// Arguments to pass to the tasks. Use ":::" to separate tasks.
#[clap(allow_hyphen_values = true, trailing_var_arg = true)]
#[clap(allow_hyphen_values = true)]
pub args: Vec<String>,

/// Arguments to pass to the tasks. Use ":::" to separate tasks.
#[clap(allow_hyphen_values = true, hide = true, last = true)]
pub args_last: Vec<String>,

/// Change to this directory before executing the command
#[clap(short = 'C', long, value_hint = ValueHint::DirPath, long)]
pub cd: Option<PathBuf>,
Expand Down Expand Up @@ -194,6 +197,7 @@ impl Run {
self.tmpdir = tmpdir.path().to_path_buf();
let args = once(self.task.clone())
.chain(self.args.clone())
.chain(self.args_last.clone())
.collect_vec();
let task_list = get_task_lists(&args, true)?;
time!("run get_task_lists");
Expand Down Expand Up @@ -988,7 +992,7 @@ pub fn get_task_lists(args: &[String], prompt: bool) -> Result<Vec<Task>> {
.cloned()
.collect_vec();
if tasks.is_empty() {
if t != "default" || !prompt {
if t != "default" || !prompt || !console::user_attended_stderr() {
err_no_task(&t)?;
}

Expand Down
5 changes: 4 additions & 1 deletion src/cli/use.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::{Path, PathBuf};

use console::{style, Term};
use eyre::{eyre, Result};
use eyre::{bail, eyre, Result};
use itertools::Itertools;
use path_absolutize::Absolutize;

Expand Down Expand Up @@ -250,6 +250,9 @@ impl Use {
}

fn tool_selector(&self) -> Result<ToolArg> {
if !console::user_attended_stderr() {
bail!("No tool specified and not running interactively");
}
let mut s = demand::Select::new("Tools")
.description("Select a tool to install")
.filtering(true)
Expand Down
Loading