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

Feature Request: Add a way to pass args to script_runner of a condition_script #1081

Open
wmmc88 opened this issue May 8, 2024 · 2 comments
Assignees
Milestone

Comments

@wmmc88
Copy link
Contributor

wmmc88 commented May 8, 2024

Feature Description

I want to do the same thing as #1025, but for a condition_script instead of a normal script block.

shebang support for condition scripts was added to resolve #987, but it looks like there isn't an equivalent to script_runner_args to pass args to the script runner selected by the shebang. I would like to pass args to the rust-script runner for the same reasons as in #1025.

Describe The Solution You'd Like

Since the syntax for condition_script is slightly different that normal script, I'm not sure what the solution should look like. The simplest thing may by just to have a condition_script_runner_args field, but that is a little odd because there is no accompanying condition_script_runner field (i.e. using different runners only works via shebangs).

@wmmc88
Copy link
Contributor Author

wmmc88 commented May 9, 2024

Currently, I am working around this with a plugin, but I think this would be better suited inside of cargo-make itself. Especially since afaik, there is no way to run multiple different plugins.

[plugins.impl.rust-condition-script-cargo_make_current_task_initial_makefile_directory-substitution]
script = '''
# Parse task json into variables
taskjson = json_parse ${task.as_json}

# Convert backslashes to forward slashes
rust-driver-toolchian-path = replace ${taskjson.env.CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY} "\\" "/"

# Replace the ${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY} variable in the condition_script with the rust-driver-toolchian-path
taskjson.condition_script = replace ${taskjson.condition_script} "\${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}" "${rust-driver-toolchian-path}"

# Reencode variables into json
taskjson = json_encode taskjson

# Run the invoking task, with the modified condition_script
cm_plugin_run_custom_task ${taskjson}
'''

@sagiegurari
Copy link
Owner

@wmmc88 this is now available in the dev branch 0.37.13 and i would love your feedback as i did really bare minimum of tests.

@sagiegurari sagiegurari added this to the 0.37.13 milestone May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants