Skip to content
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

Unexpected behavior with flag #162

Open
arthurh4 opened this issue Nov 9, 2024 · 1 comment
Open

Unexpected behavior with flag #162

arthurh4 opened this issue Nov 9, 2024 · 1 comment

Comments

@arthurh4
Copy link

arthurh4 commented Nov 9, 2024

hello, i'm currently testing the usage support for mise task and testing the --force flag from the example.

I have the following script:

#!/usr/bin/env bash
#USAGE flag "-f --force" help="Overwrite existing <file>" count=true
#USAGE flag "-u --user <user>" help="User to run as"
#USAGE arg "<file>" help="The file to write" default="file.txt"
#USAGE arg "<arg_with_default>" help="An arg with a default" default="mydefault"
#MISE description="This is a test cmd1 script"
#MISE alias="cd1"
echo "all: $@"
echo "usage_force: $usage_force"
echo "usage_user: $usage_user"
echo "usage_file: $usage_file"
echo "usage_arg_with_default: $usage_arg_with_default"

but when running several tests:

# mise run java:cmd1 -f
[java:cmd1] $ ~/.config/mise/tasks/java/cmd1
all:
usage_force:
usage_user:
usage_file: file.txt
usage_arg_with_default: mydefault
# mise run java:cmd1 -f --user=test
[java:cmd1] $ ~/.config/mise/tasks/java/cmd1 --user=test
all: --user=test
usage_force:
usage_user: test
usage_file: file.txt
usage_arg_with_default: mydefault
# mise run java:cmd1 -f --user=test -f
[java:cmd1] $ ~/.config/mise/tasks/java/cmd1 --user=test -f
all: --user=test -f
usage_force: true
usage_user: test
usage_file: file.txt
usage_arg_with_default: mydefault

you can see that -f only become true when the user flag is also set and the -f is set after the user flag, is this an expected behavior ? or am I missing something ?
thank you

@jdx
Copy link
Owner

jdx commented Nov 9, 2024

you need to use mise run -- java:cmd1 -f to prevent mise run from grabbing -f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants