From 9653a49acbd48089607194b5897de163672f76a8 Mon Sep 17 00:00:00 2001 From: jdx <216188+jdx@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:08:12 -0600 Subject: [PATCH] fix: trap panics in task resolving (#3677) * fix: trap panics in task resolving * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- Cargo.lock | 84 +++++++++++++------------- Cargo.toml | 2 +- docs/cli/config/set.md | 10 ++-- docs/cli/en.md | 4 -- docs/cli/exec.md | 12 ++-- docs/cli/index.md | 4 +- docs/cli/latest.md | 2 - docs/cli/link.md | 2 - docs/cli/ls-remote.md | 4 -- docs/cli/ls.md | 4 -- docs/cli/outdated.md | 4 -- docs/cli/plugins/install.md | 6 -- docs/cli/plugins/link.md | 2 - docs/cli/plugins/ls.md | 2 - docs/cli/registry.md | 2 - docs/cli/run.md | 8 --- docs/cli/set.md | 6 +- docs/cli/settings.md | 6 -- docs/cli/settings/ls.md | 2 - docs/cli/tasks.md | 2 +- docs/cli/tasks/add.md | 4 +- docs/cli/tasks/deps.md | 4 -- docs/cli/tasks/info.md | 2 - docs/cli/tasks/run.md | 8 --- docs/cli/trust.md | 2 - docs/cli/uninstall.md | 4 -- docs/cli/unset.md | 2 - docs/cli/upgrade.md | 12 ---- docs/cli/use.md | 8 --- docs/cli/watch.md | 6 -- docs/cli/where.md | 2 - docs/cli/which.md | 4 -- e2e/tasks/test_task_help | 11 ++++ mise.lock | 2 +- mise.usage.kdl | 104 ++++++++++++++++----------------- src/cli/generate/task_docs.rs | 2 +- src/cli/run.rs | 5 ++ src/task/task_script_parser.rs | 12 +++- tasks.md | 6 -- tasks.toml | 2 +- xtasks/release-plz | 3 +- 41 files changed, 140 insertions(+), 233 deletions(-) create mode 100644 e2e/tasks/test_task_help diff --git a/Cargo.lock b/Cargo.lock index c2f26506c8..393776856f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,9 +60,9 @@ dependencies = [ [[package]] name = "age" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edeef7d7b199195a2d7d7a8155d2d04aee736e60c5c7bdd7097d115369a8817d" +checksum = "77de71da1ca673855aacea507a7aed363beb8934cf61b62364fc4b479d2e8cda" dependencies = [ "age-core", "base64 0.21.7", @@ -693,15 +693,15 @@ dependencies = [ [[package]] name = "console" -version = "0.15.8" +version = "0.15.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b" dependencies = [ "encode_unicode", - "lazy_static", "libc", - "unicode-width 0.1.14", - "windows-sys 0.52.0", + "once_cell", + "unicode-width 0.2.0", + "windows-sys 0.59.0", ] [[package]] @@ -1155,9 +1155,9 @@ dependencies = [ [[package]] name = "encode_unicode" -version = "0.3.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "encoding_rs" @@ -1269,7 +1269,7 @@ dependencies = [ "pest_derive", "regex", "strum", - "thiserror 2.0.7", + "thiserror 2.0.8", ] [[package]] @@ -1339,7 +1339,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", + "miniz_oxide 0.8.2", ] [[package]] @@ -1774,9 +1774,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", @@ -1794,9 +1794,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.3" +version = "0.27.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +checksum = "f6884a48c6826ec44f524c7456b163cebe9e55a18d7b5e307cb4f100371cc767" dependencies = [ "futures-util", "http", @@ -2576,9 +2576,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ "adler2", ] @@ -2678,7 +2678,7 @@ dependencies = [ "tera", "terminal_size", "test-log", - "thiserror 2.0.7", + "thiserror 2.0.8", "tokio", "toml 0.8.19", "toml_edit", @@ -3035,7 +3035,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" dependencies = [ "memchr", - "thiserror 2.0.7", + "thiserror 2.0.8", "ucd-trie", ] @@ -3306,7 +3306,7 @@ dependencies = [ "rustc-hash 2.1.0", "rustls", "socket2", - "thiserror 2.0.7", + "thiserror 2.0.8", "tokio", "tracing", ] @@ -3325,7 +3325,7 @@ dependencies = [ "rustls", "rustls-pki-types", "slab", - "thiserror 2.0.7", + "thiserror 2.0.8", "tinyvec", "tracing", "web-time", @@ -3333,9 +3333,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52cd4b1eff68bf27940dd39811292c49e007f4d0b4c357358dc9b0197be6b527" +checksum = "1c40286217b4ba3a71d644d752e6a0b71f13f1b6a2c5311acfcbe0c2418ed904" dependencies = [ "cfg_aliases", "libc", @@ -3703,7 +3703,7 @@ dependencies = [ "openssl-probe", "rustls-pki-types", "schannel", - "security-framework 3.0.1", + "security-framework 3.1.0", ] [[package]] @@ -3815,9 +3815,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "3.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1415a607e92bec364ea2cf9264646dcce0f91e6d65281bd6f2819cca3bf39c8" +checksum = "81d3f8c9bfcc3cbb6b0179eb57042d75b1582bdc65c3cb95f3fa999509c03cbc" dependencies = [ "bitflags", "core-foundation 0.10.0", @@ -3828,9 +3828,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.1" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" dependencies = [ "core-foundation-sys", "libc", @@ -4467,11 +4467,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.7" +version = "2.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93605438cbd668185516ab499d589afb7ee1859ea3d5fc8f6b0755e1c7443767" +checksum = "08f5383f3e0071702bf93ab5ee99b52d26936be9dedd9413067cbdcddcb6141a" dependencies = [ - "thiserror-impl 2.0.7", + "thiserror-impl 2.0.8", ] [[package]] @@ -4487,9 +4487,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.7" +version = "2.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d8749b4531af2117677a5fcd12b1348a3fe2b81e36e61ffeac5c4aa3273e36" +checksum = "f2f357fcec90b3caef6623a099691be676d033b40a058ac95d2a6ade6fa0c943" dependencies = [ "proc-macro2", "quote", @@ -4790,7 +4790,7 @@ dependencies = [ "serde", "strum", "tempfile", - "thiserror 2.0.7", + "thiserror 2.0.8", "url", "which 7.0.0", "xz2", @@ -4938,9 +4938,9 @@ checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" [[package]] name = "usage-lib" -version = "1.6.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd75b195d7d5e9232b7b0f5a76d2e13ca4b8ac765180aa37737adec4baa28ad1" +checksum = "f8e8e596b6aabf5e0f7589a08facfccb63ee1668d071c26c321f64d7c7050fd2" dependencies = [ "clap", "heck 0.5.0", @@ -4955,7 +4955,7 @@ dependencies = [ "shell-words", "strum", "tera", - "thiserror 2.0.7", + "thiserror 2.0.8", "versions", "xx", ] @@ -5023,7 +5023,7 @@ dependencies = [ "serde", "serde_json", "tempfile", - "thiserror 2.0.7", + "thiserror 2.0.8", "tokio", "url", "xx", @@ -5540,7 +5540,7 @@ dependencies = [ "reqwest", "sha2", "tar", - "thiserror 2.0.7", + "thiserror 2.0.8", "tokio", "xz2", "zip", @@ -5671,9 +5671,9 @@ dependencies = [ [[package]] name = "zip" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d52293fc86ea7cf13971b3bb81eb21683636e7ae24c729cdaf1b7c4157a352" +checksum = "ae9c1ea7b3a5e1f4b922ff856a129881167511563dc219869afe3787fc0c1a45" dependencies = [ "aes", "arbitrary", @@ -5691,7 +5691,7 @@ dependencies = [ "pbkdf2", "rand", "sha1", - "thiserror 2.0.7", + "thiserror 2.0.8", "time", "zeroize", "zopfli", diff --git a/Cargo.toml b/Cargo.toml index 0d837f3083..a6f3cdfbb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,7 +78,7 @@ git2 = "<1" glob = "0.3" globset = "0.4" heck = "0.5" -home = "0.5" +home = "= 0.5.9" # TODO: bump this when we can bump msrv humantime = "2" indenter = "0.3" indexmap = { version = "2", features = ["serde"] } diff --git a/docs/cli/config/set.md b/docs/cli/config/set.md index 38fd6c32cc..0391ab02d4 100644 --- a/docs/cli/config/set.md +++ b/docs/cli/config/set.md @@ -37,13 +37,11 @@ If not provided, the nearest mise.toml file will be used Examples: ``` -mise config set tools.python 3.12 -mise config set settings.always_keep_download true -mise config set env.TEST_ENV_VAR ABC -mise config set settings.disable_tools --type list node,rust -``` +$ mise config set tools.python 3.12 +$ mise config set settings.always_keep_download true +$ mise config set env.TEST_ENV_VAR ABC +$ mise config set settings.disable_tools --type list node,rust -``` # Type for `settings` is inferred $ mise config set settings.jobs 4 ``` diff --git a/docs/cli/en.md b/docs/cli/en.md index c8876fda07..70d0235126 100644 --- a/docs/cli/en.md +++ b/docs/cli/en.md @@ -31,14 +31,10 @@ Examples: $ mise en . $ node -v v20.0.0 -``` -``` Skip loading bashrc: $ mise en -s "bash --norc" -``` -``` Skip loading zshrc: $ mise en -s "zsh -f" ``` diff --git a/docs/cli/exec.md b/docs/cli/exec.md index c564f9ca35..4901e13683 100644 --- a/docs/cli/exec.md +++ b/docs/cli/exec.md @@ -1,6 +1,6 @@ # `mise exec` -- **Usage**: `mise exec [FLAGS] [TOOL@VERSION]... [COMMAND]...` +- **Usage**: `mise exec [FLAGS] [TOOL@VERSION]... [-- COMMAND]...` - **Aliases**: `x` - **Source code**: [`src/cli/exec.rs`](https://github.com/jdx/mise/blob/main/src/cli/exec.rs) @@ -20,7 +20,7 @@ The "--" separates runtimes from the commands to pass along to the subprocess. Tool(s) to start e.g.: node@20 python@3.10 -### `[COMMAND]...` +### `[-- COMMAND]...` Command string to execute (same as --command) @@ -42,16 +42,12 @@ Directly pipe stdin/stdout/stderr from plugin to user Sets --jobs=1 Examples: ``` -mise exec node@20 -- node ./app.js # launch app.js using node-20.x -mise x node@20 -- node ./app.js # shorter alias -``` +$ mise exec node@20 -- node ./app.js # launch app.js using node-20.x +$ mise x node@20 -- node ./app.js # shorter alias -``` # Specify command as a string: $ mise exec node@20 python@3.11 --command "node -v && python -V" -``` -``` # Run a command in a different directory: $ mise x -C /path/to/project node@20 -- node ./app.js ``` diff --git a/docs/cli/index.md b/docs/cli/index.md index a0d3c0571f..7e1d2e1b4a 100644 --- a/docs/cli/index.md +++ b/docs/cli/index.md @@ -79,7 +79,7 @@ Can also use `MISE_NO_CONFIG=1` - [`mise doctor path [-f --full]`](/cli/doctor/path.md) - [`mise en [-s --shell ] [DIR]`](/cli/en.md) - [`mise env [FLAGS] [TOOL@VERSION]...`](/cli/env.md) -- [`mise exec [FLAGS] [TOOL@VERSION]... [COMMAND]...`](/cli/exec.md) +- [`mise exec [FLAGS] [TOOL@VERSION]... [-- COMMAND]...`](/cli/exec.md) - [`mise fmt [-a --all]`](/cli/fmt.md) - [`mise generate `](/cli/generate.md) - [`mise generate git-pre-commit [FLAGS]`](/cli/generate/git-pre-commit.md) @@ -117,7 +117,7 @@ Can also use `MISE_NO_CONFIG=1` - [`mise sync python [--pyenv] [--uv]`](/cli/sync/python.md) - [`mise sync ruby [--brew]`](/cli/sync/ruby.md) - [`mise tasks [FLAGS] [TASK] `](/cli/tasks.md) -- [`mise tasks add [FLAGS] [RUN]...`](/cli/tasks/add.md) +- [`mise tasks add [FLAGS] [-- RUN]...`](/cli/tasks/add.md) - [`mise tasks deps [--hidden] [--dot] [TASKS]...`](/cli/tasks/deps.md) - [`mise tasks edit [-p --path] `](/cli/tasks/edit.md) - [`mise tasks info [-J --json] `](/cli/tasks/info.md) diff --git a/docs/cli/latest.md b/docs/cli/latest.md index 73c0f4cf9d..21a4e0b191 100644 --- a/docs/cli/latest.md +++ b/docs/cli/latest.md @@ -24,9 +24,7 @@ Examples: ``` $ mise latest node@20 # get the latest version of node 20 20.0.0 -``` -``` $ mise latest node # get the latest stable version of node 20.0.0 ``` diff --git a/docs/cli/link.md b/docs/cli/link.md index b1cff81d90..910ade93ba 100644 --- a/docs/cli/link.md +++ b/docs/cli/link.md @@ -31,9 +31,7 @@ Examples: # build node-20.0.0 with node-build and link it into mise $ node-build 20.0.0 ~/.nodes/20.0.0 $ mise link node@20.0.0 ~/.nodes/20.0.0 -``` -``` # have mise use the python version provided by Homebrew $ brew install node $ mise link node@brew $(brew --prefix node) diff --git a/docs/cli/ls-remote.md b/docs/cli/ls-remote.md index 9e19ef8c98..20499b182a 100644 --- a/docs/cli/ls-remote.md +++ b/docs/cli/ls-remote.md @@ -30,15 +30,11 @@ Examples: $ mise ls-remote node 18.0.0 20.0.0 -``` -``` $ mise ls-remote node@20 20.0.0 20.1.0 -``` -``` $ mise ls-remote node 20 20.0.0 20.1.0 diff --git a/docs/cli/ls.md b/docs/cli/ls.md index 65d9030969..cd0b923a4a 100644 --- a/docs/cli/ls.md +++ b/docs/cli/ls.md @@ -63,15 +63,11 @@ $ mise ls node 20.0.0 ~/src/myapp/.tool-versions latest python 3.11.0 ~/.tool-versions 3.10 python 3.10.0 -``` -``` $ mise ls --current node 20.0.0 ~/src/myapp/.tool-versions 20 python 3.11.0 ~/.tool-versions 3.11.0 -``` -``` $ mise ls --json { "node": [ diff --git a/docs/cli/outdated.md b/docs/cli/outdated.md index f5b12f2c64..87d4c846dd 100644 --- a/docs/cli/outdated.md +++ b/docs/cli/outdated.md @@ -41,15 +41,11 @@ $ mise outdated Plugin Requested Current Latest python 3.11 3.11.0 3.11.1 node 20 20.0.0 20.1.0 -``` -``` $ mise outdated node Plugin Requested Current Latest node 20 20.0.0 20.1.0 -``` -``` $ mise outdated --json {"python": {"requested": "3.11", "current": "3.11.0", "latest": "3.11.1"}, ...} ``` diff --git a/docs/cli/plugins/install.md b/docs/cli/plugins/install.md index ec86567543..47cf3d1601 100644 --- a/docs/cli/plugins/install.md +++ b/docs/cli/plugins/install.md @@ -44,20 +44,14 @@ Examples: ``` # install the node via shorthand $ mise plugins install node -``` -``` # install the node plugin using a specific git url $ mise plugins install node https://github.com/mise-plugins/rtx-nodejs.git -``` -``` # install the node plugin using the git url only # (node is inferred from the url) $ mise plugins install https://github.com/mise-plugins/rtx-nodejs.git -``` -``` # install the node plugin using a specific ref $ mise plugins install node https://github.com/mise-plugins/rtx-nodejs.git#v1.0.0 ``` diff --git a/docs/cli/plugins/link.md b/docs/cli/plugins/link.md index 4d5e16306a..8148b7f77c 100644 --- a/docs/cli/plugins/link.md +++ b/docs/cli/plugins/link.md @@ -31,9 +31,7 @@ Examples: ``` # essentially just `ln -s ./mise-node ~/.local/share/mise/plugins/node` $ mise plugins link node ./mise-node -``` -``` # infer plugin name as "node" $ mise plugins link ./mise-node ``` diff --git a/docs/cli/plugins/ls.md b/docs/cli/plugins/ls.md index c426f306de..522e812df4 100644 --- a/docs/cli/plugins/ls.md +++ b/docs/cli/plugins/ls.md @@ -21,9 +21,7 @@ Examples: $ mise plugins ls node ruby -``` -``` $ mise plugins ls --urls node https://github.com/asdf-vm/asdf-nodejs.git ruby https://github.com/asdf-vm/asdf-ruby.git diff --git a/docs/cli/registry.md b/docs/cli/registry.md index a03a74a588..2125410204 100644 --- a/docs/cli/registry.md +++ b/docs/cli/registry.md @@ -32,9 +32,7 @@ $ mise registry node core:node poetry asdf:mise-plugins/mise-poetry ubi cargo:ubi-cli -``` -``` $ mise registry poetry asdf:mise-plugins/mise-poetry ``` diff --git a/docs/cli/run.md b/docs/cli/run.md index 592121664b..0b13a159e0 100644 --- a/docs/cli/run.md +++ b/docs/cli/run.md @@ -103,25 +103,17 @@ Examples: # Runs the "lint" tasks. This needs to either be defined in mise.toml # or as a standalone script. See the project README for more information. $ mise run lint -``` -``` # Forces the "build" tasks to run even if its sources are up-to-date. $ mise run build --force -``` -``` # Run "test" with stdin/stdout/stderr all connected to the current terminal. # This forces `--jobs=1` to prevent interleaving of output. $ mise run test --raw -``` -``` # Runs the "lint", "test", and "check" tasks in parallel. $ mise run lint ::: test ::: check -``` -``` # Execute multiple tasks each with their own arguments. $ mise tasks cmd1 arg1 arg2 ::: cmd2 arg1 arg2 ``` diff --git a/docs/cli/set.md b/docs/cli/set.md index d51a902bc6..a2b61e8aba 100644 --- a/docs/cli/set.md +++ b/docs/cli/set.md @@ -29,15 +29,11 @@ Set the environment variable in the global config file Examples: ``` -mise set NODE_ENV=production -``` +$ mise set NODE_ENV=production -``` $ mise set NODE_ENV production -``` -``` $ mise set key value source NODE_ENV production ~/.config/mise/config.toml diff --git a/docs/cli/settings.md b/docs/cli/settings.md index ca0530c276..6b25d89e3b 100644 --- a/docs/cli/settings.md +++ b/docs/cli/settings.md @@ -52,19 +52,13 @@ Examples: ``` # list all settings $ mise settings -``` -``` # get the value of the setting "always_keep_download" $ mise settings always_keep_download -``` -``` # set the value of the setting "always_keep_download" to "true" $ mise settings always_keep_download=true -``` -``` # set the value of the setting "node.mirror_url" to "https://npm.taobao.org/mirrors/node" $ mise settings node.mirror_url https://npm.taobao.org/mirrors/node ``` diff --git a/docs/cli/settings/ls.md b/docs/cli/settings/ls.md index 6c82a3b147..50918583d1 100644 --- a/docs/cli/settings/ls.md +++ b/docs/cli/settings/ls.md @@ -45,9 +45,7 @@ Examples: $ mise settings ls idiomatic_version_file = false ... -``` -``` $ mise settings ls python default_packages_file = "~/.default-python-packages" ... diff --git a/docs/cli/tasks.md b/docs/cli/tasks.md index 7f4478dabe..d5a6c145f2 100644 --- a/docs/cli/tasks.md +++ b/docs/cli/tasks.md @@ -52,7 +52,7 @@ Output in JSON format ## Subcommands -- [`mise tasks add [FLAGS] [RUN]...`](/cli/tasks/add.md) +- [`mise tasks add [FLAGS] [-- RUN]...`](/cli/tasks/add.md) - [`mise tasks deps [--hidden] [--dot] [TASKS]...`](/cli/tasks/deps.md) - [`mise tasks edit [-p --path] `](/cli/tasks/edit.md) - [`mise tasks info [-J --json] `](/cli/tasks/info.md) diff --git a/docs/cli/tasks/add.md b/docs/cli/tasks/add.md index 0cb6423cd4..e7277f102e 100644 --- a/docs/cli/tasks/add.md +++ b/docs/cli/tasks/add.md @@ -1,6 +1,6 @@ # `mise tasks add` -- **Usage**: `mise tasks add [FLAGS] [RUN]...` +- **Usage**: `mise tasks add [FLAGS] [-- RUN]...` - **Source code**: [`src/cli/tasks/add.rs`](https://github.com/jdx/mise/blob/main/src/cli/tasks/add.rs) Create a new task @@ -11,7 +11,7 @@ Create a new task Tasks name to add -### `[RUN]...` +### `[-- RUN]...` ## Flags diff --git a/docs/cli/tasks/deps.md b/docs/cli/tasks/deps.md index ea1fbcc787..0fde45eddc 100644 --- a/docs/cli/tasks/deps.md +++ b/docs/cli/tasks/deps.md @@ -28,14 +28,10 @@ Examples: ``` # Show dependencies for all tasks $ mise tasks deps -``` -``` # Show dependencies for the "lint", "test" and "check" tasks $ mise tasks deps lint test check -``` -``` # Show dependencies in DOT format $ mise tasks deps --dot ``` diff --git a/docs/cli/tasks/info.md b/docs/cli/tasks/info.md index 13da54ddc7..ebad5ec193 100644 --- a/docs/cli/tasks/info.md +++ b/docs/cli/tasks/info.md @@ -25,9 +25,7 @@ Name: test Aliases: t Description: Test the application Source: ~/src/myproj/mise.toml -``` -``` $ mise tasks info test --json { "name": "test", diff --git a/docs/cli/tasks/run.md b/docs/cli/tasks/run.md index decc6f56ba..74710256c7 100644 --- a/docs/cli/tasks/run.md +++ b/docs/cli/tasks/run.md @@ -117,25 +117,17 @@ Examples: # Runs the "lint" tasks. This needs to either be defined in mise.toml # or as a standalone script. See the project README for more information. $ mise run lint -``` -``` # Forces the "build" tasks to run even if its sources are up-to-date. $ mise run build --force -``` -``` # Run "test" with stdin/stdout/stderr all connected to the current terminal. # This forces `--jobs=1` to prevent interleaving of output. $ mise run test --raw -``` -``` # Runs the "lint", "test", and "check" tasks in parallel. $ mise run lint ::: test ::: check -``` -``` # Execute multiple tasks each with their own arguments. $ mise tasks cmd1 arg1 arg2 ::: cmd2 arg1 arg2 ``` diff --git a/docs/cli/trust.md b/docs/cli/trust.md index 2efa27a977..5b86955881 100644 --- a/docs/cli/trust.md +++ b/docs/cli/trust.md @@ -44,9 +44,7 @@ Examples: ``` # trusts ~/some_dir/mise.toml $ mise trust ~/some_dir/mise.toml -``` -``` # trusts mise.toml in the current or parent directory $ mise trust ``` diff --git a/docs/cli/uninstall.md b/docs/cli/uninstall.md index 49013396c5..01e6afef5a 100644 --- a/docs/cli/uninstall.md +++ b/docs/cli/uninstall.md @@ -29,14 +29,10 @@ Examples: ``` # will uninstall specific version $ mise uninstall node@18.0.0 -``` -``` # will uninstall the current node version (if only one version is installed) $ mise uninstall node -``` -``` # will uninstall all installed versions of node $ mise uninstall --all node@18.0.0 # will uninstall all node versions ``` diff --git a/docs/cli/unset.md b/docs/cli/unset.md index 19efc43559..bb9ab2402e 100644 --- a/docs/cli/unset.md +++ b/docs/cli/unset.md @@ -29,9 +29,7 @@ Examples: ``` # Remove NODE_ENV from the current directory's config $ mise unset NODE_ENV -``` -``` # Remove NODE_ENV from the global config $ mise unset NODE_ENV -g ``` diff --git a/docs/cli/upgrade.md b/docs/cli/upgrade.md index cfcad64c2a..40af4f60f3 100644 --- a/docs/cli/upgrade.md +++ b/docs/cli/upgrade.md @@ -54,34 +54,22 @@ Examples: ``` # Upgrades node to the latest version matching the range in mise.toml $ mise upgrade node -``` -``` # Upgrades node to the latest version and bumps the version in mise.toml $ mise upgrade node --bump -``` -``` # Upgrades all tools to the latest versions $ mise upgrade -``` -``` # Upgrades all tools to the latest versions and bumps the version in mise.toml $ mise upgrade --bump -``` -``` # Just print what would be done, don't actually do it $ mise upgrade --dry-run -``` -``` # Upgrades node and python to the latest versions $ mise upgrade node python -``` -``` # Show a multiselect menu to choose which tools to upgrade $ mise upgrade --interactive ``` diff --git a/docs/cli/use.md b/docs/cli/use.md index 64c7d21520..e81a07c586 100644 --- a/docs/cli/use.md +++ b/docs/cli/use.md @@ -88,26 +88,18 @@ Examples: # run with no arguments to use the interactive selector $ mise use -``` -``` # set the current version of node to 20.x in mise.toml of current directory # will write the fuzzy version (e.g.: 20) $ mise use node@20 -``` -``` # set the current version of node to 20.x in ~/.config/mise/config.toml # will write the precise version (e.g.: 20.0.0) $ mise use -g --pin node@20 -``` -``` # sets .mise.local.toml (which is intended not to be committed to a project) $ mise use --env local node@20 -``` -``` # sets .mise.staging.toml (which is used if MISE_ENV=staging) $ mise use --env staging node@20 ``` diff --git a/docs/cli/watch.md b/docs/cli/watch.md index bb6f0abaa9..3bb92d1270 100644 --- a/docs/cli/watch.md +++ b/docs/cli/watch.md @@ -610,20 +610,14 @@ Examples: $ mise watch build Runs the "build" tasks. Will re-run the tasks when any of its sources change. Uses "sources" from the tasks definition to determine which files to watch. -``` -``` $ mise watch build --glob src/**/*.rs Runs the "build" tasks but specify the files to watch with a glob pattern. This overrides the "sources" from the tasks definition. -``` -``` $ mise watch build --clear Extra arguments are passed to watchexec. See `watchexec --help` for details. -``` -``` $ mise watch serve --watch src --exts rs --restart Starts an api server, watching for changes to "*.rs" files in "./src" and kills/restarts the server when they change. ``` diff --git a/docs/cli/where.md b/docs/cli/where.md index 37bc52ff94..d869fb44a9 100644 --- a/docs/cli/where.md +++ b/docs/cli/where.md @@ -24,9 +24,7 @@ Examples: # If it is is not installed, errors $ mise where node@20 /home/jdx/.local/share/mise/installs/node/20.0.0 -``` -``` # Show the current, active install directory of node # Errors if node is not referenced in any .tool-version file $ mise where node diff --git a/docs/cli/which.md b/docs/cli/which.md index bf705b77b6..2900338216 100644 --- a/docs/cli/which.md +++ b/docs/cli/which.md @@ -33,14 +33,10 @@ Examples: ``` $ mise which node /home/username/.local/share/mise/installs/node/20.0.0/bin/node -``` -``` $ mise which node --plugin node -``` -``` $ mise which node --version 20.0.0 ``` diff --git a/e2e/tasks/test_task_help b/e2e/tasks/test_task_help new file mode 100644 index 0000000000..af7ffacf73 --- /dev/null +++ b/e2e/tasks/test_task_help @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +cat <mise.toml +[tasks.a] +run = 'echo {{arg(name="myarg")}}' +EOF + +assert "mise run a --help 2>&1 || true" "Usage: a + +Arguments: + " diff --git a/mise.lock b/mise.lock index e05efad42b..daf51196a6 100644 --- a/mise.lock +++ b/mise.lock @@ -44,7 +44,7 @@ version = "0.2.3" backend = "cargo:toml-cli" [tools."cargo:usage-cli"] -version = "1.6.0" +version = "1.7.2" backend = "cargo:usage-cli" [tools.cosign] diff --git a/mise.usage.kdl b/mise.usage.kdl index 0cf0e17812..ac87bd5507 100644 --- a/mise.usage.kdl +++ b/mise.usage.kdl @@ -56,8 +56,8 @@ flag "-q --quiet" help="Suppress non-error messages" global=true flag "--silent" help="Suppress all task output and mise non-error messages" global=true 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 `." -arg "[TASK_ARGS]..." help="Task arguments" var=true hide=true +arg "[TASK]" help="Task to run" help_long="Task to run.\n\nShorthand for `mise task run `." required=false +arg "[TASK_ARGS]..." help="Task arguments" 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 @@ -95,7 +95,7 @@ Customize status output with `status` settings."# flag "--no-hook-env" help="Do not automatically call hook-env" { long_help "Do not automatically call hook-env\n\nThis can be helpful for debugging mise. If you run `eval \"$(mise activate --no-hook-env)\"`, then you can call `mise hook-env` manually which will output the env vars to stdout without actually modifying the environment. That way you can do things like `mise hook-env --trace` to get more information or just see the values that hook-env is outputting." } - arg "[SHELL_TYPE]" help="Shell type to generate the script for" { + arg "[SHELL_TYPE]" help="Shell type to generate the script for" required=false { choices "bash" "elvish" "fish" "nu" "xonsh" "zsh" "pwsh" } } @@ -134,7 +134,7 @@ For user config, aliases are defined like the following in `~/.config/mise/confi node lts-jod 22 " flag "--no-header" help="Don't show table header" - arg "[TOOL]" help="Show aliases for " + arg "[TOOL]" help="Show aliases for " required=false } cmd "set" help="Add/update an alias for a plugin" { alias "add" "create" @@ -163,7 +163,7 @@ This modifies the contents of ~/.config/mise/config.toml" } } cmd "asdf" hide=true help="[internal] simulates asdf for plugins that call \"asdf\" internally" { - arg "[ARGS]..." help="all arguments" var=true + arg "[ARGS]..." help="all arguments" required=false double_dash="automatic" var=true } cmd "backends" help="Manage backends" { alias "b" @@ -183,7 +183,7 @@ cmd "backends" help="Manage backends" { } } cmd "bin-paths" help="List all the active runtime bin paths" { - arg "[TOOL@VERSION]..." help="Tool(s) to look up\ne.g.: ruby@3" var=true + arg "[TOOL@VERSION]..." help="Tool(s) to look up\ne.g.: ruby@3" required=false var=true } cmd "cache" help="Manage the mise cache" { long_help r"Manage the mise cache @@ -193,7 +193,7 @@ Run `mise cache` with no args to view the current cache directory." alias "c" alias "clean" hide=true flag "--outdate" help="Mark all cache files as old" hide=true - arg "[PLUGIN]..." help="Plugin(s) to clear cache for e.g.: node, python" var=true + arg "[PLUGIN]..." help="Plugin(s) to clear cache for e.g.: node, python" required=false var=true } cmd "prune" help="Removes stale mise cache files" { alias "p" @@ -203,7 +203,7 @@ By default, this command will remove files that have not been accessed in 30 day Change this with the MISE_CACHE_PRUNE_AGE environment variable." flag "--dry-run" help="Just show what would be pruned" flag "-v --verbose" help="Show pruned files" var=true count=true - arg "[PLUGIN]..." help="Plugin(s) to clear cache for e.g.: node, python" var=true + arg "[PLUGIN]..." help="Plugin(s) to clear cache for e.g.: node, python" required=false var=true } } cmd "completion" help="Generate shell completions" { @@ -225,7 +225,7 @@ cmd "completion" help="Generate shell completions" { flag "--include-bash-completion-lib" help="Include the bash completion library in the bash completion script" { long_help "Include the bash completion library in the bash completion script\n\nThis is required for completions to work in bash, but it is not included by default\nyou may source it separately or enable this flag to include it in the script." } - arg "[SHELL]" help="Shell type to generate completions for" { + arg "[SHELL]" help="Shell type to generate completions for" required=false { choices "bash" "fish" "zsh" } } @@ -255,7 +255,7 @@ cmd "config" help="Manage config files" { long_help "The path to the mise.toml file to edit\n\nIf not provided, the nearest mise.toml file will be used" arg "" } - arg "[KEY]" help="The path of the config to display" + arg "[KEY]" help="The path of the config to display" required=false } cmd "ls" help="List config files currently in use" { alias "list" @@ -314,7 +314,7 @@ and/or version. It's designed to fit into scripts more easily." $ mise current python 3.11.0 3.10.0 " - arg "[PLUGIN]" help="Plugin to show versions of e.g.: ruby, node, cargo:eza, npm:prettier, etc" + arg "[PLUGIN]" help="Plugin to show versions of e.g.: ruby, node, cargo:eza, npm:prettier, etc" required=false } cmd "deactivate" help="Disable mise for current shell session" { long_help r"Disable mise for current shell session @@ -393,7 +393,7 @@ Note that changing directories will not update the mise environment." long_help "Shell to start\n\nDefaults to $SHELL" arg "" } - arg "[DIR]" help="Directory to start the shell in" default="." + arg "[DIR]" help="Directory to start the shell in" required=false default="." } cmd "env" help="Exports env vars to activate mise a single time" { alias "e" @@ -416,7 +416,7 @@ use this if you have `mise activate` in your shell rc file." choices "bash" "elvish" "fish" "nu" "xonsh" "zsh" "pwsh" } } - arg "[TOOL@VERSION]..." help="Tool(s) to use" var=true + arg "[TOOL@VERSION]..." help="Tool(s) to use" required=false var=true } cmd "exec" help="Execute a command with tool(s) set" { alias "x" @@ -447,8 +447,8 @@ The "--" separates runtimes from the commands to pass along to the subprocess."# arg "" } flag "--raw" help="Directly pipe stdin/stdout/stderr from plugin to user Sets --jobs=1" - arg "[TOOL@VERSION]..." help="Tool(s) to start e.g.: node@20 python@3.10" var=true - arg "[COMMAND]..." help="Command string to execute (same as --command)" var=true + arg "[TOOL@VERSION]..." help="Tool(s) to start e.g.: node@20 python@3.10" required=false var=true + arg "[-- COMMAND]..." help="Command string to execute (same as --command)" required=false var=true } cmd "fmt" help="Formats mise.toml" { long_help r"Formats mise.toml @@ -556,7 +556,7 @@ Use `mise local` to set a tool version locally in the current directory." arg "" } flag "--path" help="Get the path of the global config file" - arg "[TOOL@VERSION]..." help="Tool(s) to add to .tool-versions\ne.g.: node@20\nIf this is a single tool with no version, the current value of the global\n.tool-versions will be displayed" var=true + arg "[TOOL@VERSION]..." help="Tool(s) to add to .tool-versions\ne.g.: node@20\nIf this is a single tool with no version, the current value of the global\n.tool-versions will be displayed" required=false var=true } cmd "hook-env" hide=true help="[internal] called by activate hook to update env vars directory change" { flag "-s --shell" help="Shell type to generate script for" { @@ -609,7 +609,7 @@ Tools will be installed in parallel. To disable, set `--jobs=1` or `MISE_JOBS=1` flag "-v --verbose" help="Show installation output" var=true count=true { long_help "Show installation output\n\nThis argument will print plugin output such as download, configuration, and compilation output." } - arg "[TOOL@VERSION]..." help="Tool(s) to install e.g.: node@20" var=true + arg "[TOOL@VERSION]..." help="Tool(s) to install e.g.: node@20" required=false var=true } cmd "latest" help="Gets the latest available version for a plugin" { long_help r"Gets the latest available version for a plugin @@ -625,7 +625,7 @@ Supports prefixes such as `node@20` to get the latest version of node 20." " flag "-i --installed" help="Show latest installed instead of available version" arg "" help="Tool to get the latest version of" - arg "[ASDF_VERSION]" help="The version prefix to use when querying the latest version same as the first argument after the \"@\" used for asdf compatibility" hide=true + arg "[ASDF_VERSION]" help="The version prefix to use when querying the latest version same as the first argument after the \"@\" used for asdf compatibility" required=false hide=true } cmd "link" help="Symlinks a tool version into mise" { alias "ln" @@ -681,7 +681,7 @@ is set. A future v2 release of mise will default to using `mise.toml`." arg "" } flag "--path" help="Get the path of the config file" - arg "[TOOL@VERSION]..." help="Tool(s) to add to .tool-versions/mise.toml\ne.g.: node@20\nif this is a single tool with no version,\nthe current value of .tool-versions/mise.toml will be displayed" var=true + arg "[TOOL@VERSION]..." help="Tool(s) to add to .tool-versions/mise.toml\ne.g.: node@20\nif this is a single tool with no version,\nthe current value of .tool-versions/mise.toml will be displayed" required=false var=true } cmd "ls" help="List installed and active tool versions" { alias "list" @@ -732,7 +732,7 @@ It's a useful command to get the current state of your tools."# arg "" } flag "--no-header" help="Don't display headers" - arg "[PLUGIN]..." help="Only show tool versions from [PLUGIN]" var=true + arg "[PLUGIN]..." help="Only show tool versions from [PLUGIN]" required=false var=true } cmd "ls-remote" help="List runtime versions available for install." { alias "list-all" "list-remote" hide=true @@ -754,8 +754,8 @@ Note that the results may be cached, run `mise cache clean` to clear the cache a 20.1.0 " flag "--all" help="Show all installed plugins and versions" - arg "[TOOL@VERSION]" help="Tool to get versions for" - arg "[PREFIX]" help="The version prefix to use when querying the latest version\nsame as the first argument after the \"@\"" + arg "[TOOL@VERSION]" help="Tool to get versions for" required=false + arg "[PREFIX]" help="The version prefix to use when querying the latest version\nsame as the first argument after the \"@\"" required=false } cmd "outdated" help="Shows outdated tool versions" { long_help r"Shows outdated tool versions @@ -780,7 +780,7 @@ See `mise upgrade` to upgrade these versions." } flag "-J --json" help="Output in JSON format" flag "--no-header" help="Don't show table header" - arg "[TOOL@VERSION]..." help="Tool(s) to show outdated versions for\ne.g.: node@20 python@3.10\nIf not specified, all tools in global and local configs will be shown" var=true + arg "[TOOL@VERSION]..." help="Tool(s) to show outdated versions for\ne.g.: node@20 python@3.10\nIf not specified, all tools in global and local configs will be shown" required=false var=true } cmd "plugins" help="Manage plugins" { alias "p" @@ -820,9 +820,9 @@ This behavior can be modified in ~/.config/mise/config.toml" flag "-f --force" help="Reinstall even if plugin exists" flag "-a --all" help="Install all missing plugins\nThis will only install plugins that have matching shorthands.\ni.e.: they don't need the full git repo url" flag "-v --verbose" help="Show installation output" var=true count=true - arg "[NEW_PLUGIN]" help="The name of the plugin to install\ne.g.: node, ruby\nCan specify multiple plugins: `mise plugins install node ruby python`" - arg "[GIT_URL]" help="The git url of the plugin" - arg "[REST]..." var=true hide=true + arg "[NEW_PLUGIN]" help="The name of the plugin to install\ne.g.: node, ruby\nCan specify multiple plugins: `mise plugins install node ruby python`" required=false + arg "[GIT_URL]" help="The git url of the plugin" required=false + arg "[REST]..." required=false var=true hide=true } cmd "link" help="Symlinks a plugin into mise" { alias "ln" @@ -839,7 +839,7 @@ This is used for developing a plugin." "# flag "-f --force" help="Overwrite existing plugin" arg "" help="The name of the plugin\ne.g.: node, ruby" - arg "[DIR]" help="The local path to the plugin\ne.g.: ./mise-node" + arg "[DIR]" help="The local path to the plugin\ne.g.: ./mise-node" required=false } cmd "ls" help="List installed plugins" { alias "list" @@ -884,7 +884,7 @@ Examples: " flag "-p --purge" help="Also remove the plugin's installs, downloads, and cache" flag "-a --all" help="Remove all plugins" - arg "[PLUGIN]..." help="Plugin(s) to remove" var=true + arg "[PLUGIN]..." help="Plugin(s) to remove" required=false var=true } cmd "update" help="Updates a plugin to the latest version" { alias "up" "upgrade" @@ -900,7 +900,7 @@ note: this updates the plugin itself, not the runtime versions" flag "-j --jobs" help="Number of jobs to run in parallel\nDefault: 4" { arg "" } - arg "[PLUGIN]..." help="Plugin(s) to update" var=true + arg "[PLUGIN]..." help="Plugin(s) to update" required=false var=true } } cmd "prune" help="Delete unused versions of tools" { @@ -919,7 +919,7 @@ as will versions only referenced on the command line `mise exec @" } flag "--hide-aliased" help="Hide aliased tools" - arg "[NAME]" help="Show only the specified tool's full name" + arg "[NAME]" help="Show only the specified tool's full name" required=false } cmd "reshim" help="Creates new shims based on bin paths from currently installed tools." { long_help r#"Creates new shims based on bin paths from currently installed tools. @@ -969,8 +969,8 @@ currently active in mise.toml."# v20.0.0 " flag "-f --force" help="Removes all shims before reshimming" - arg "[PLUGIN]" hide=true - arg "[VERSION]" hide=true + arg "[PLUGIN]" required=false hide=true + arg "[VERSION]" required=false hide=true } cmd "run" help="Run task(s)" { alias "r" @@ -1057,7 +1057,7 @@ This command is not available if mise is installed via a package manager." flag "-f --force" help="Update even if already up to date" flag "--no-plugins" help="Disable auto-updating plugins" flag "-y --yes" help="Skip confirmation prompt" - arg "[VERSION]" help="Update to a specific version" + arg "[VERSION]" help="Update to a specific version" required=false } cmd "set" help="Set environment variables in mise.toml" { alias "ev" "env-vars" hide=true @@ -1084,7 +1084,7 @@ By default, this command modifies `mise.toml` in the current directory." long_help "Remove the environment variable from config file\n\nCan be used multiple times." arg "" } - arg "[ENV_VARS]..." help="Environment variable(s) to set\ne.g.: NODE_ENV=production" var=true + arg "[ENV_VARS]..." help="Environment variable(s) to set\ne.g.: NODE_ENV=production" required=false var=true } cmd "settings" help="Manage settings" { after_long_help r#"Examples: @@ -1105,8 +1105,8 @@ cmd "settings" help="Manage settings" { flag "-J --json" help="Output in JSON format" flag "--json-extended" help="Output in JSON format with sources" flag "-T --toml" help="Output in TOML format" - arg "[KEY]" help="Setting name to get/set" - arg "[VALUE]" help="Setting value to set" + arg "[KEY]" help="Setting name to get/set" required=false + arg "[VALUE]" help="Setting value to set" required=false cmd "add" help="Adds a setting to the configuration file" { long_help r"Adds a setting to the configuration file @@ -1158,7 +1158,7 @@ but managed separately with `mise aliases`" flag "-J --json" help="Output in JSON format" flag "--json-extended" help="Output in JSON format with sources" flag "-T --toml" help="Output in TOML format" - arg "[KEY]" help="List keys under this key" + arg "[KEY]" help="List keys under this key" required=false } cmd "set" help="Add/update a setting" { alias "create" @@ -1277,7 +1277,7 @@ cmd "tasks" help="Manage tasks" { } flag "-J --json" help="Output in JSON format" global=true flag "--usage" hide=true global=true - arg "[TASK]" help="Task name to get info of" + arg "[TASK]" help="Task name to get info of" required=false cmd "add" help="Create a new task" { after_long_help r#"Examples: @@ -1319,7 +1319,7 @@ cmd "tasks" help="Manage tasks" { } flag "-f --file" help="Create a file task instead of a toml task" arg "" help="Tasks name to add" - arg "[RUN]..." var=true + arg "[-- RUN]..." required=false var=true } cmd "deps" help="Display a tree visualization of a dependency graph" { after_long_help r#"Examples: @@ -1335,7 +1335,7 @@ cmd "tasks" help="Manage tasks" { "# flag "--hidden" help="Show hidden tasks" flag "--dot" help="Display dependencies in DOT format" - arg "[TASKS]..." help="Tasks to show dependencies for\nCan specify multiple tasks by separating with spaces\ne.g.: mise tasks deps lint test check" var=true + arg "[TASKS]..." help="Tasks to show dependencies for\nCan specify multiple tasks by separating with spaces\ne.g.: mise tasks deps lint test check" required=false var=true } cmd "edit" help="Edit a tasks with $EDITOR" { long_help r"Edit a tasks with $EDITOR @@ -1481,8 +1481,8 @@ The name of the script will be the name of the tasks. } flag "-q --quiet" help="Don't show extra output" flag "-S --silent" help="Don't show any output except for errors" - arg "[TASK]" help="Tasks to run\nCan specify multiple tasks by separating with `:::`\ne.g.: mise run task1 arg1 arg2 ::: task2 arg1 arg2" default="default" - arg "[ARGS]..." help="Arguments to pass to the tasks. Use \":::\" to separate tasks" var=true + 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 mount run="mise tasks --usage" } } @@ -1497,7 +1497,7 @@ cmd "test-tool" hide=true help="Test a tool installs and executes" { arg "" } flag "--raw" help="Directly pipe stdin/stdout/stderr from plugin to user Sets --jobs=1" - arg "[TOOL]" + arg "[TOOL]" required=false } cmd "tool" help="Gets information about a tool" { after_long_help r"Examples: @@ -1542,7 +1542,7 @@ This includes: flag "--ignore" help="Do not trust this config and ignore it in the future" flag "--untrust" help="No longer trust this config, will prompt in the future" flag "--show" help="Show the trusted status of config files from the current directory and its parents.\nDoes not trust or untrust any files." - arg "[CONFIG_FILE]" help="The config file to trust" + arg "[CONFIG_FILE]" help="The config file to trust" required=false } cmd "uninstall" help="Removes installed tool versions" { alias "remove" "rm" @@ -1562,7 +1562,7 @@ This only removes the installed version, it does not modify mise.toml." " flag "-a --all" help="Delete all installed versions" flag "-n --dry-run" help="Do not actually delete anything" - arg "[INSTALLED_TOOL@VERSION]..." help="Tool(s) to remove" var=true + arg "[INSTALLED_TOOL@VERSION]..." help="Tool(s) to remove" required=false var=true } cmd "unset" help="Remove environment variable(s) from the config file." { long_help r"Remove environment variable(s) from the config file. @@ -1580,7 +1580,7 @@ By default, this command modifies `mise.toml` in the current directory." arg "" } flag "-g --global" help="Use the global config file" - arg "[KEYS]..." help="Environment variable(s) to remove\ne.g.: NODE_ENV" var=true + arg "[KEYS]..." help="Environment variable(s) to remove\ne.g.: NODE_ENV" required=false var=true } cmd "upgrade" help="Upgrades outdated tools" { alias "up" @@ -1623,7 +1623,7 @@ This will update mise.lock if it is enabled, see https://mise.jdx.dev/configurat long_help "Upgrades to the latest version available, bumping the version in mise.toml\n\nFor example, if you have `node = \"20.0.0\"` in your mise.toml but 22.1.0 is the latest available,\nthis will install 22.1.0 and set `node = \"22.1.0\"` in your config.\n\nIt keeps the same precision as what was there before, so if you instead had `node = \"20\"`, it\nwould change your config to `node = \"22\"`." } flag "--raw" help="Directly pipe stdin/stdout/stderr from plugin to user Sets --jobs=1" - arg "[TOOL@VERSION]..." help="Tool(s) to upgrade\ne.g.: node@20 python@3.10\nIf not specified, all current tools will be upgraded" var=true + arg "[TOOL@VERSION]..." help="Tool(s) to upgrade\ne.g.: node@20 python@3.10\nIf not specified, all current tools will be upgraded" required=false var=true } cmd "usage" hide=true help="Generate a usage CLI spec" { long_help r"Generate a usage CLI spec @@ -1685,7 +1685,7 @@ Use the `--global` flag to use the global config file instead."# flag "--pin" help="Save exact version to config file\ne.g.: `mise use --pin node@20` will save 20.0.0 as the version\nSet `MISE_PIN=1` to make this the default behavior" { long_help "Save exact version to config file\ne.g.: `mise use --pin node@20` will save 20.0.0 as the version\nSet `MISE_PIN=1` to make this the default behavior\n\nConsider using mise.lock as a better alternative to pinning in mise.toml:\nhttps://mise.jdx.dev/configuration/settings.html#lockfile" } - arg "[TOOL@VERSION]..." help="Tool(s) to add to config file" help_long="Tool(s) to add to config file\n\ne.g.: node@20, cargo:ripgrep@latest npm:prettier@3\nIf no version is specified, it will default to @latest\n\nTool options can be set with this syntax:\n\n mise use ubi:BurntSushi/ripgrep[exe=rg]" var=true + arg "[TOOL@VERSION]..." help="Tool(s) to add to config file" help_long="Tool(s) to add to config file\n\ne.g.: node@20, cargo:ripgrep@latest npm:prettier@3\nIf no version is specified, it will default to @latest\n\nTool options can be set with this syntax:\n\n mise use ubi:BurntSushi/ripgrep[exe=rg]" required=false var=true } cmd "version" help="Display the version of mise" { alias "v" @@ -1896,8 +1896,8 @@ It must be installed for this command to work, but you can install it with `mise flag "--manual" help="Show the manual page" { long_help "Show the manual page\n\nThis shows the manual page for Watchexec, if the output is a terminal and the 'man' program is available. If not, the manual page is printed to stdout in ROFF format (suitable for writing to a watchexec.1 file)." } - arg "[TASK]" help="Tasks to run\nCan specify multiple tasks by separating with `:::`\ne.g.: mise run task1 arg1 arg2 ::: task2 arg1 arg2" - arg "[ARGS]..." help="Task and arguments to run" var=true + 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 + arg "[ARGS]..." help="Task and arguments to run" required=false double_dash="automatic" var=true } cmd "where" help="Display the installation path for a tool" { long_help r"Display the installation path for a tool @@ -1916,7 +1916,7 @@ The tool must be installed for this to work." /home/jdx/.local/share/mise/installs/node/20.0.0 " arg "" help="Tool(s) to look up\ne.g.: ruby@3\nif \"@\" is specified, it will show the latest installed version\nthat matches the prefix\notherwise, it will show the current, active installed version" - arg "[ASDF_VERSION]" help="the version prefix to use when querying the latest version\nsame as the first argument after the \"@\"\nused for asdf compatibility" hide=true + arg "[ASDF_VERSION]" help="the version prefix to use when querying the latest version\nsame as the first argument after the \"@\"\nused for asdf compatibility" required=false hide=true } cmd "which" help="Shows the path that a tool's bin points to." { long_help r"Shows the path that a tool's bin points to. diff --git a/src/cli/generate/task_docs.rs b/src/cli/generate/task_docs.rs index 754941a0d7..a14d226f7d 100644 --- a/src/cli/generate/task_docs.rs +++ b/src/cli/generate/task_docs.rs @@ -43,7 +43,7 @@ impl TaskDocs { let dir = dirs::CWD.as_ref().unwrap(); let tasks = Config::get().load_tasks_in_dir(dir)?; let mut out = vec![]; - for task in &tasks { + for task in tasks.iter().filter(|t| !t.hide) { out.push(task.render_markdown(dir)?); } if let Some(output) = &self.output { diff --git a/src/cli/run.rs b/src/cli/run.rs index 7be5155fcc..7ef48e0a0f 100644 --- a/src/cli/run.rs +++ b/src/cli/run.rs @@ -2,6 +2,7 @@ use std::collections::{BTreeMap, HashSet}; use std::io::Write; use std::iter::once; use std::ops::Deref; +use std::panic; use std::path::{Path, PathBuf}; use std::process::Stdio; use std::sync::Mutex; @@ -231,6 +232,10 @@ impl Run { s.spawn(|_| { let task = t; let tx_err = tx_err; + panic::set_hook(Box::new(|info| { + eprintln!("panic in task: {info}"); + exit(1); + })); if !self.is_stopping() { trace!("running task: {task}"); if let Err(err) = self.run_task(&task) { diff --git a/src/task/task_script_parser.rs b/src/task/task_script_parser.rs index ae12a9b6a1..7ace87b08d 100644 --- a/src/task/task_script_parser.rs +++ b/src/task/task_script_parser.rs @@ -1,4 +1,5 @@ use crate::config::{Config, SETTINGS}; +use crate::exit::exit; use crate::shell::ShellType; use crate::task::Task; use crate::tera::get_tera; @@ -96,6 +97,7 @@ impl TaskScriptParser { hide, default, choices, + ..Default::default() }; arg.usage = arg.usage(); input_args.lock().unwrap().push(arg); @@ -311,7 +313,15 @@ pub fn replace_template_placeholders_with_args( .into_iter() .chain(args.iter().cloned()) .collect::>(); - let m = usage::parse(spec, &args).map_err(|e| eyre::eyre!(e.to_string()))?; + let m = match usage::parse(spec, &args) { + Ok(m) => m, + Err(e) => { + // just print exactly what usage returns so the error output isn't double-wrapped + // this could be displaying help or a parse error + eprintln!("{}", format!("{e}").trim_end()); + exit(1); + } + }; let mut out = vec![]; let re = regex!(r"MISE_TASK_ARG:(\w+):MISE_TASK_ARG"); for script in scripts { diff --git a/tasks.md b/tasks.md index b1d45e30a4..a34de1efff 100644 --- a/tasks.md +++ b/tasks.md @@ -273,9 +273,3 @@ run unit tests ## `update-descriptions` - **Usage**: `update-descriptions` - -## `xxx` - -- **Usage**: `xxx` - -a task for testing diff --git a/tasks.toml b/tasks.toml index 20f339c0d7..b214f2dc9f 100644 --- a/tasks.toml +++ b/tasks.toml @@ -130,5 +130,5 @@ run = "cargo install --path . --debug" [xxx] hide = true tools = { gh = "2.60.0" } -run = "gh --version" +run = "echo {{arg(name='greeting')}}" description = "a task for testing" diff --git a/xtasks/release-plz b/xtasks/release-plz index 67bc445dab..893271d2bc 100755 --- a/xtasks/release-plz +++ b/xtasks/release-plz @@ -38,8 +38,7 @@ sed -i.bak "s/version = \"[0-9]\+\.[0-9]\+\.[0-9]\+\(-rc\.[0-9]\+\)\?\";$/versio mise run render ::: lint-fix -# disable until next kdl-rs has compatible miette -#cargo update +cargo update git add \ Cargo.lock \ Cargo.toml \