-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(task): add --name-only flag to mise tasks ls #9435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0f22254
802fc86
cae576b
26d5bb0
79226d5
146f3f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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" | ||
| assert_fail "mise tasks ls --name-only --usage" | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
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, | ||||||||||||||||||||||||
|
|
@@ -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(":", "\\:"); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.