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
4 changes: 4 additions & 0 deletions docs/cli/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ By default, only tasks from the current directory hierarchy are loaded.

Show hidden tasks

### `--name-only`

Only show task names, one per line. Useful for piping to fzf and similar tools.

### `--no-header`

Do not print table header
Expand Down
4 changes: 4 additions & 0 deletions docs/cli/tasks/ls.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ By default, only tasks from the current directory hierarchy are loaded.

Show hidden tasks

### `--name-only`

Only show task names, one per line. Useful for piping to fzf and similar tools.

### `--no-header`

Do not print table header
Expand Down
51 changes: 51 additions & 0 deletions e2e/tasks/test_task_ls_name_only
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

cat <<EOF >mise.toml
[tasks.build]
description = "build the project"
run = 'echo build'
[tasks.lint]
description = "lint the code"
run = 'echo lint'
[tasks.test]
description = "run the tests"
run = 'echo test'
EOF

mkdir -p .mise/tasks
cat <<'EOF' >.mise/tasks/deploy
#!/usr/bin/env bash
# mise description="deploy the app"
echo deploy
EOF
chmod +x .mise/tasks/deploy

assert "mise tasks ls --name-only" "build
deploy
lint
test"

# --no-header is harmless and the output is identical
assert "mise tasks ls --name-only --no-header" "build
deploy
lint
test"

# Composes with --sort/--sort-order
assert "mise tasks ls --name-only --sort name --sort-order desc" "test
lint
deploy
build"

# Local/global filtering still applies
echo "tasks.myglobal = { run = 'echo myglobal' }" >~/.config/mise/config.toml
assert "mise tasks ls --name-only --global" "myglobal"
assert "mise tasks ls --name-only --local" "build
deploy
lint
test"

# Conflicts with other output formats
assert_fail "mise tasks ls --name-only --json"
assert_fail "mise tasks ls --name-only -x"
Comment thread
greptile-apps[bot] marked this conversation as resolved.
assert_fail "mise tasks ls --name-only --usage"
6 changes: 6 additions & 0 deletions man/man1/mise.1
Original file line number Diff line number Diff line change
Expand Up @@ -2648,6 +2648,9 @@ Display tasks for usage completion
\fB\-\-hidden\fR
Show hidden tasks
.TP
\fB\-\-name\-only\fR
Only show task names, one per line. Useful for piping to fzf and similar tools.
.TP
\fB\-\-no\-header\fR
Do not print table header
.TP
Expand Down Expand Up @@ -2811,6 +2814,9 @@ Display tasks for usage completion
\fB\-\-hidden\fR
Show hidden tasks
.TP
\fB\-\-name\-only\fR
Only show task names, one per line. Useful for piping to fzf and similar tools.
.TP
\fB\-\-no\-header\fR
Do not print table header
.TP
Expand Down
2 changes: 2 additions & 0 deletions mise.usage.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,7 @@ cmd tasks help="Manage tasks" {
flag --all help="Load all tasks from the entire monorepo, including sibling directories.\nBy default, only tasks from the current directory hierarchy are loaded." global=#true
flag --complete help="Display tasks for usage completion" hide=#true
flag --hidden help="Show hidden tasks" global=#true
flag --name-only help="Only show task names, one per line. Useful for piping to fzf and similar tools." global=#true
flag --no-header help="Do not print table header" global=#true
flag --sort help="Sort by column. Default is name." global=#true {
arg <COLUMN> {
Expand Down Expand Up @@ -1150,6 +1151,7 @@ cmd tasks help="Manage tasks" {
flag --all help="Load all tasks from the entire monorepo, including sibling directories.\nBy default, only tasks from the current directory hierarchy are loaded." global=#true
flag --complete help="Display tasks for usage completion" hide=#true
flag --hidden help="Show hidden tasks" global=#true
flag --name-only help="Only show task names, one per line. Useful for piping to fzf and similar tools." global=#true
flag --no-header help="Do not print table header" global=#true
flag --sort help="Sort by column. Default is name." global=#true {
arg <COLUMN> {
Expand Down
18 changes: 18 additions & 0 deletions src/cli/tasks/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ pub struct TasksLs {
#[clap(long, global = true, verbatim_doc_comment)]
pub hidden: bool,

/// Only show task names, one per line. Useful for piping to fzf and similar tools.
#[clap(
long,
global = true,
verbatim_doc_comment,
conflicts_with_all = ["json", "extended", "usage"]
)]
Comment on lines +67 to +72

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The --name-only flag should be marked as global = true to maintain consistency with other output-related flags in this struct (like --json and --extended). This ensures the flag is correctly categorized in help output and behaves consistently when used at different levels of the command hierarchy (e.g., mise tasks --name-only ls).

Suggested change
#[clap(
long,
verbatim_doc_comment,
conflicts_with_all = ["json", "extended", "complete", "usage"]
)]
#[clap(
long,
global = true,
verbatim_doc_comment,
conflicts_with_all = ["json", "extended", "complete", "usage"]
)]

Comment thread
greptile-apps[bot] marked this conversation as resolved.
pub name_only: bool,

/// Do not print table header
#[clap(long, alias = "no-headers", global = true, verbatim_doc_comment)]
pub no_header: bool,
Expand Down Expand Up @@ -144,12 +153,21 @@ impl TasksLs {
self.display_usage(&config, tasks).await?;
} else if self.json {
self.display_json(&config, tasks).await?;
} else if self.name_only {
self.display_name_only(tasks)?;
} else {
self.display(tasks)?;
}
Ok(())
}

fn display_name_only(&self, tasks: Vec<Task>) -> Result<()> {
for t in tasks {
calm_io::stdoutln!("{}", t.display_name)?;
}
Ok(())
}

fn complete(&self, tasks: Vec<Task>) -> Result<()> {
for t in tasks {
let name = t.display_name.replace(":", "\\:");
Expand Down
12 changes: 12 additions & 0 deletions xtasks/fig/src/mise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3306,6 +3306,12 @@ const completionSpec: Fig.Spec = {
description: "Show hidden tasks",
isRepeatable: false,
},
{
name: "--name-only",
description:
"Only show task names, one per line. Useful for piping to fzf and similar tools.",
isRepeatable: false,
},
{
name: "--no-header",
description: "Do not print table header",
Expand Down Expand Up @@ -3599,6 +3605,12 @@ const completionSpec: Fig.Spec = {
description: "Show hidden tasks",
isRepeatable: false,
},
{
name: "--name-only",
description:
"Only show task names, one per line. Useful for piping to fzf and similar tools.",
isRepeatable: false,
},
{
name: "--no-header",
description: "Do not print table header",
Expand Down
Loading