Skip to content

Commit

Permalink
Merge branch 'main' into regex-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx authored Oct 25, 2024
2 parents 555de0d + 46ecc5d commit a71acdb
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 75 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions docs/cli/activate.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ Customize status output with `status` settings.

Shell type to generate the script for

**Choices:**

- `bash`
- `fish`
- `nu`
- `xonsh`
- `zsh`

## Flags

### `--shims`
Expand Down
6 changes: 6 additions & 0 deletions docs/cli/completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ Generate shell completions

Shell type to generate completions for

**Choices:**

- `bash`
- `fish`
- `zsh`

Examples:

mise completion bash > /etc/bash_completion.d/mise
Expand Down
7 changes: 7 additions & 0 deletions docs/cli/config/set.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ If not provided, the nearest mise.toml file will be used

### `-t --type <TYPE>`

**Choices:**

- `string`
- `integer`
- `float`
- `bool`

Examples:

mise config set tools.python 3.12
Expand Down
8 changes: 8 additions & 0 deletions docs/cli/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ Output in JSON format

Shell type to generate environment variables for

**Choices:**

- `bash`
- `fish`
- `nu`
- `xonsh`
- `zsh`

Examples:

eval "$(mise env -s bash)"
Expand Down
5 changes: 5 additions & 0 deletions docs/cli/generate/task-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ root directory to search for tasks

### `-s --style <STYLE>`

**Choices:**

- `simple`
- `detailed`

Examples:

mise generate task-docs
12 changes: 12 additions & 0 deletions docs/cli/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,22 @@ Show hidden tasks

Sort by column. Default is name.

**Choices:**

- `name`
- `alias`
- `description`
- `source`

### `--sort-order <SORT_ORDER>`

Sort order. Default is asc.

**Choices:**

- `asc`
- `desc`

### `-J --json`

Output in JSON format
Expand Down
12 changes: 12 additions & 0 deletions docs/cli/tasks/ls.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,22 @@ Show hidden tasks

Sort by column. Default is name.

**Choices:**

- `name`
- `alias`
- `description`
- `source`

### `--sort-order <SORT_ORDER>`

Sort order. Default is asc.

**Choices:**

- `asc`
- `desc`

### `-J --json`

Output in JSON format
Expand Down
11 changes: 7 additions & 4 deletions e2e/tasks/test_task_run → e2e/tasks/test_task_run_file
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ run = 'echo "configtask:"'
run = 'echo "linting!"'
[tasks.test]
run = 'echo "testing!"'
[tasks.test-with-args]
run = 'echo "{{arg()}} {{flag(name="force")}} {{option(name="user")}}"'
EOF

mkdir -p .mise/tasks
Expand All @@ -34,13 +32,18 @@ assert "cat test-e2e/test-build-output.txt" "TEST_BUILDSCRIPT_ENV_VAR: VALID
ARGS: arg1 arg2"

assert "mise run test arg1 arg2 arg3" "testing! arg1 arg2 arg3"
assert "mise run test-with-args foo --force --user=user" "foo true user"

cat <<'EOF' >.mise/tasks/filetask
#!/usr/bin/env bash
#USAGE flag "-u --user <user>" help="User to run as"
#USAGE flag "-p --port <port>" help="Port to run on" default="8080"
echo "user=$usage_user"
echo "port=$usage_port"
EOF
assert "mise run filetask --user=jdx" "user=jdx"
assert "mise run filetask --user=jdx" "user=jdx
port=8080"
assert "mise run filetask --port=8081" "user=
port=8081"
assert_contains "mise run filetask --help 2>&1 || true" "-u --user <user>"
assert_contains "mise run filetask --help 2>&1 || true" "-p --port <port>"
19 changes: 19 additions & 0 deletions e2e/tasks/test_task_run_toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

cat <<EOF >.mise.toml
[tasks.configtask]
run = 'echo "configtask:"'
[tasks.lint]
run = 'echo "linting!"'
[tasks.test]
run = 'echo "testing!"'
[tasks.test-with-args]
run = 'echo "{{arg()}} {{flag(name="force")}} {{option(name="user")}}"'
[tasks.test-with-defaults]
run = 'echo {{arg(default="arg1")}} {{option(name="user", default="user1")}}'
EOF

assert "mise run test arg1 arg2 arg3" "testing! arg1 arg2 arg3"
assert "mise run test-with-args foo --force --user=user" "foo true user"
assert "mise run test-with-defaults" "arg1 user1"
assert "mise run test-with-defaults arg2 --user=user2" "arg2 user2"
56 changes: 42 additions & 14 deletions mise.usage.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ flag "-P --profile" help="Set the profile (environment)" global=true {
}
flag "--debug" help="Sets log level to debug" hide=true global=true
flag "--log-level" help="Set the log output verbosity" hide=true global=true {
arg "<LEVEL>"
arg "<LEVEL>" {
choices "error" "warn" "info" "debug" "trace"
}
}
flag "-q --quiet" help="Suppress non-error messages" global=true
flag "--trace" help="Sets log level to trace" hide=true global=true
Expand Down Expand Up @@ -53,14 +55,18 @@ Customize status output with `status` settings."#
$ execx($(mise activate xonsh))
"#
flag "-s --shell" help="Shell type to generate the script for" hide=true {
arg "<SHELL>"
arg "<SHELL>" {
choices "bash" "fish" "nu" "xonsh" "zsh"
}
}
flag "--status" help="Show \"mise: <PLUGIN>@<VERSION>\" message when changing directories" hide=true
flag "--shims" help="Use shims instead of modifying PATH\nEffectively the same as:" {
long_help "Use shims instead of modifying PATH\nEffectively the same as:\n\n PATH=\"$HOME/.local/share/mise/shims:$PATH\""
}
flag "-q --quiet" help="Suppress non-error messages"
arg "[SHELL_TYPE]" help="Shell type to generate the script for"
arg "[SHELL_TYPE]" help="Shell type to generate the script for" {
choices "bash" "fish" "nu" "xonsh" "zsh"
}
}
cmd "alias" help="Manage aliases" {
alias "a"
Expand Down Expand Up @@ -175,12 +181,16 @@ cmd "completion" help="Generate shell completions" {
$ mise completion fish > ~/.config/fish/completions/mise.fish
"
flag "-s --shell" help="Shell type to generate completions for" hide=true {
arg "<SHELL_TYPE>"
arg "<SHELL_TYPE>" {
choices "bash" "fish" "zsh"
}
}
flag "--usage" help="Always use usage for completions.\nCurrently, usage is the default for fish and bash but not zsh since it has a few quirks\nto work out first." hide=true {
long_help "Always use usage for completions.\nCurrently, usage is the default for fish and bash but not zsh since it has a few quirks\nto work out first.\n\nThis requires the `usage` CLI to be installed.\nhttps://usage.jdx.dev"
}
arg "[SHELL]" help="Shell type to generate completions for"
arg "[SHELL]" help="Shell type to generate completions for" {
choices "bash" "fish" "zsh"
}
}
cmd "config" help="Manage config files" {
alias "cfg"
Expand Down Expand Up @@ -230,7 +240,9 @@ cmd "config" help="Manage config files" {
arg "<FILE>"
}
flag "-t --type" {
arg "<TYPE>"
arg "<TYPE>" {
choices "string" "integer" "float" "bool"
}
}
arg "<KEY>" help="The path of the config to display"
arg "<VALUE>" help="The value to set the key to"
Expand Down Expand Up @@ -317,7 +329,9 @@ use this if you have `mise activate` in your shell rc file."
"#
flag "-J --json" help="Output in JSON format"
flag "-s --shell" help="Shell type to generate environment variables for" {
arg "<SHELL>"
arg "<SHELL>" {
choices "bash" "fish" "nu" "xonsh" "zsh"
}
}
arg "[TOOL@VERSION]..." help="Tool(s) to use" var=true
}
Expand Down Expand Up @@ -410,7 +424,9 @@ when you push changes to your repository."
arg "<ROOT>"
}
flag "-s --style" {
arg "<STYLE>"
arg "<STYLE>" {
choices "simple" "detailed"
}
}
}
}
Expand Down Expand Up @@ -448,14 +464,18 @@ Use `mise local` to set a tool version locally in the current directory."
}
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" {
arg "<SHELL>"
arg "<SHELL>" {
choices "bash" "fish" "nu" "xonsh" "zsh"
}
}
flag "--status" help="Show \"mise: <PLUGIN>@<VERSION>\" message when changing directories" hide=true
flag "-q --quiet" help="Hide warnings such as when a tool is not installed"
}
cmd "hook-not-found" hide=true help="[internal] called by shell when a command is not found" {
flag "-s --shell" help="Shell type to generate script for" {
arg "<SHELL>"
arg "<SHELL>" {
choices "bash" "fish" "nu" "xonsh" "zsh"
}
}
arg "<BIN>" help="Attempted bin to run"
}
Expand Down Expand Up @@ -1078,10 +1098,14 @@ cmd "tasks" help="[experimental] Manage tasks" {
flag "-x --extended" help="Show all columns"
flag "--hidden" help="Show hidden tasks"
flag "--sort" help="Sort by column. Default is name." {
arg "<COLUMN>"
arg "<COLUMN>" {
choices "name" "alias" "description" "source"
}
}
flag "--sort-order" help="Sort order. Default is asc." {
arg "<SORT_ORDER>"
arg "<SORT_ORDER>" {
choices "asc" "desc"
}
}
flag "-J --json" help="Output in JSON format"
flag "--usage" hide=true
Expand Down Expand Up @@ -1161,10 +1185,14 @@ tasks will override the global ones if they have the same name."
flag "-x --extended" help="Show all columns"
flag "--hidden" help="Show hidden tasks"
flag "--sort" help="Sort by column. Default is name." {
arg "<COLUMN>"
arg "<COLUMN>" {
choices "name" "alias" "description" "source"
}
}
flag "--sort-order" help="Sort order. Default is asc." {
arg "<SORT_ORDER>"
arg "<SORT_ORDER>" {
choices "asc" "desc"
}
}
flag "-J --json" help="Output in JSON format"
flag "--usage" hide=true
Expand Down
2 changes: 1 addition & 1 deletion src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl Task {
let (spec, scripts) = self.parse_usage_spec(cwd)?;
if has_any_args_defined(&spec) {
Ok(
replace_template_placeholders_with_args(&spec, &scripts, args)
replace_template_placeholders_with_args(&spec, &scripts, args)?
.into_iter()
.map(|s| (s, vec![]))
.collect(),
Expand Down
Loading

0 comments on commit a71acdb

Please sign in to comment.