Closed
Description
Discussed in #4069
Originally posted by gturi January 12, 2025
I think it would be very useful to make mise populate the environment with the arguments and flags declared in the usage
section before running the run
section. In this way, tasks definition is made inside toml configuration, while their complex "implementation" is left inside the actual script.
[tasks.add-user]
description = "Add a user"
usage = '''
arg "<user>" default="unknown"
complete "user" run="mise run list-users-completion"
'''
run = 'node /path/to/test.js'
[tasks.list-users-completion]
hide = true
quiet = true
description = "List users"
run = 'echo "alice bob charlie"'
// test.js
const { usage_user } = process.env;
console.log(`Adding user '${usage_user}'`);
Current output: Adding user 'undefined'
This enhancement also avoids the declaration of arguments both in usage
and run
section to make them work:
[tasks.add-user]
description = "Add a user"
usage = '''
arg "<user>"
'''
# the following definition feels a bit redundant
# since I have already defined "user" argument in the usage section
run = 'echo {{arg(name="user")}}'
#run = 'echo $usage_user' # does not work
Metadata
Assignees
Labels
No labels
Activity