fix(cli/run): inherit stdio by --raw even when redactions are enabled (#4446)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: jdx <216188+jdx@users.noreply.github.com>
This commit is contained in:
Risu 2025-02-20 01:23:14 +11:00 committed by GitHub
parent 6c3b3339d2
commit 6b6fea71b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 18 additions and 7 deletions

View File

@ -73,6 +73,7 @@ Configure with `jobs` config or `MISE_JOBS` env var
### `-r --raw` ### `-r --raw`
Read/write directly to stdin/stdout/stderr instead of by line Read/write directly to stdin/stdout/stderr instead of by line
Redactions are not applied with this option
Configure with `raw` config or `MISE_RAW` env var Configure with `raw` config or `MISE_RAW` env var
### `--no-timings` ### `--no-timings`

View File

@ -87,6 +87,7 @@ Configure with `jobs` config or `MISE_JOBS` env var
### `-r --raw` ### `-r --raw`
Read/write directly to stdin/stdout/stderr instead of by line Read/write directly to stdin/stdout/stderr instead of by line
Redactions are not applied with this option
Configure with `raw` config or `MISE_RAW` env var Configure with `raw` config or `MISE_RAW` env var
### `--no-timings` ### `--no-timings`

View File

@ -18,7 +18,7 @@ label. By printing line-by-line we avoid interleaving output from parallel execu
To just print stdout/stderr directly, use `--interleave`, the `task_output` setting, or `MISE_TASK_OUTPUT=interleave`. To just print stdout/stderr directly, use `--interleave`, the `task_output` setting, or `MISE_TASK_OUTPUT=interleave`.
Stdin is not read by default. To enable this, set `raw = true` on the task that needs it. This will prevent Stdin is not read by default. To enable this, set `raw = true` on the task that needs it. This will prevent
it running in parallel with any other task-a RWMutex will get a write lock in this case. it running in parallel with any other task-a RWMutex will get a write lock in this case. This also prevents redactions applied to the output.
Extra arguments will be passed to the task, for example, if we want to run in release mode: Extra arguments will be passed to the task, for example, if we want to run in release mode:

View File

@ -602,7 +602,7 @@ cmd run help="Run task(s)" {
flag "-j --jobs" help="Number of tasks to run in parallel\n[default: 4]\nConfigure with `jobs` config or `MISE_JOBS` env var" { flag "-j --jobs" help="Number of tasks to run in parallel\n[default: 4]\nConfigure with `jobs` config or `MISE_JOBS` env var" {
arg <JOBS> arg <JOBS>
} }
flag "-r --raw" help="Read/write directly to stdin/stdout/stderr instead of by line\nConfigure with `raw` config or `MISE_RAW` env var" flag "-r --raw" help="Read/write directly to stdin/stdout/stderr instead of by line\nRedactions are not applied with this option\nConfigure with `raw` config or `MISE_RAW` env var"
flag --timings help="Shows elapsed time after each task completes" hide=#true { flag --timings help="Shows elapsed time after each task completes" hide=#true {
long_help "Shows elapsed time after each task completes\n\nDefault to always show with `MISE_TASK_TIMINGS=1`" long_help "Shows elapsed time after each task completes\n\nDefault to always show with `MISE_TASK_TIMINGS=1`"
} }
@ -843,7 +843,7 @@ cmd tasks help="Manage tasks" {
flag "-j --jobs" help="Number of tasks to run in parallel\n[default: 4]\nConfigure with `jobs` config or `MISE_JOBS` env var" { flag "-j --jobs" help="Number of tasks to run in parallel\n[default: 4]\nConfigure with `jobs` config or `MISE_JOBS` env var" {
arg <JOBS> arg <JOBS>
} }
flag "-r --raw" help="Read/write directly to stdin/stdout/stderr instead of by line\nConfigure with `raw` config or `MISE_RAW` env var" flag "-r --raw" help="Read/write directly to stdin/stdout/stderr instead of by line\nRedactions are not applied with this option\nConfigure with `raw` config or `MISE_RAW` env var"
flag --timings help="Shows elapsed time after each task completes" hide=#true { flag --timings help="Shows elapsed time after each task completes" hide=#true {
long_help "Shows elapsed time after each task completes\n\nDefault to always show with `MISE_TASK_TIMINGS=1`" long_help "Shows elapsed time after each task completes\n\nDefault to always show with `MISE_TASK_TIMINGS=1`"
} }

View File

@ -144,6 +144,7 @@ pub struct Run {
pub jobs: Option<usize>, pub jobs: Option<usize>,
/// Read/write directly to stdin/stdout/stderr instead of by line /// Read/write directly to stdin/stdout/stderr instead of by line
/// Redactions are not applied with this option
/// Configure with `raw` config or `MISE_RAW` env var /// Configure with `raw` config or `MISE_RAW` env var
#[clap(long, short, verbatim_doc_comment)] #[clap(long, short, verbatim_doc_comment)]
pub raw: bool, pub raw: bool,
@ -629,11 +630,19 @@ impl Run {
let config = Config::get(); let config = Config::get();
let program = program.to_executable(); let program = program.to_executable();
let redactions = config.redactions(); let redactions = config.redactions();
let raw = self.raw(Some(task));
let mut cmd = CmdLineRunner::new(program.clone()) let mut cmd = CmdLineRunner::new(program.clone())
.args(args) .args(args)
.envs(env) .envs(env)
.redact(redactions.deref().clone()) .redact(redactions.deref().clone())
.raw(self.raw(Some(task))); .raw(raw);
if raw && !redactions.is_empty() {
hint!(
"raw_redactions",
"--raw will prevent mise from being able to use redactions",
""
);
}
let output = self.output(Some(task)); let output = self.output(Some(task));
cmd.with_pass_signals(); cmd.with_pass_signals();
match output { match output {
@ -697,7 +706,7 @@ impl Run {
cmd = cmd.stdout(Stdio::null()).stderr(Stdio::null()); cmd = cmd.stdout(Stdio::null()).stderr(Stdio::null());
} }
TaskOutput::Quiet | TaskOutput::Interleave => { TaskOutput::Quiet | TaskOutput::Interleave => {
if redactions.is_empty() { if raw || redactions.is_empty() {
cmd = cmd cmd = cmd
.stdin(Stdio::inherit()) .stdin(Stdio::inherit())
.stdout(Stdio::inherit()) .stdout(Stdio::inherit())

View File

@ -1767,7 +1767,7 @@ const completionSpec: Fig.Spec = {
{ {
name: ["-r", "--raw"], name: ["-r", "--raw"],
description: description:
"Read/write directly to stdin/stdout/stderr instead of by line\nConfigure with `raw` config or `MISE_RAW` env var", "Read/write directly to stdin/stdout/stderr instead of by line\nRedactions are not applied with this option\nConfigure with `raw` config or `MISE_RAW` env var",
isRepeatable: false, isRepeatable: false,
}, },
{ {
@ -2411,7 +2411,7 @@ const completionSpec: Fig.Spec = {
{ {
name: ["-r", "--raw"], name: ["-r", "--raw"],
description: description:
"Read/write directly to stdin/stdout/stderr instead of by line\nConfigure with `raw` config or `MISE_RAW` env var", "Read/write directly to stdin/stdout/stderr instead of by line\nRedactions are not applied with this option\nConfigure with `raw` config or `MISE_RAW` env var",
isRepeatable: false, isRepeatable: false,
}, },
{ {