jdx / jdx/usage

Unable to pass --verbose flag to mise task via usage

Open
#285 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1k
Forks
59
Avg merge
5h 58m
Merged PRs (30d)
362

Description

Hey there 👋 !

I've recently added a `--verbose` option to one of my mise tasks, alongside a bunch of other `#USAGE` flags and arguments. Everything works as expected, other than the `--verbose` flag.

What I've observed is that, if the `--verbose` flag is the first parameter, it seems to be grabbed by mise and not passed to the task.

This can be replicated with a minimal task like:

``` Bash
#!/usr/bin/env bash

#MISE description="Sample task."

#USAGE flag "--verbose" help="Output extra debug logging."
#USAGE flag "--other-flag" help="Random extra test flag."
#USAGE flag "--force" help="Ignore caches."

if [ "$usage_verbose" = "true" ] ; then
echo "Verbose"
else
echo "Not verbose"
fi

if [ "$usage_force" = "true" ] ; then
echo "Force"
else
echo "Do not force"
fi
```

Running `mise run sample-task --verbose` results in the unexpected output:
```
Not verbose
Do not force
```

Running `mise run sample-task --other-flag --verbose` results in the expected output:
```
Verbose
Do not force
```

Is there anything I need to change in my usage config, or should I be running tasks in a different way? This issue looks similar to https://github.com/jdx/usage/issues/162, but the solution suggested on that ticket just appears to open the interactive task selector for me.

Any guidance is appreciated 🙇‍♂.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.