Skip to content

Is there a way to create subcommands? #651

Discussion options

You must be logged in to vote

here is an example. its very interesting question so I created an example and updated the README,
see https://github.com/sagiegurari/cargo-make#usage-command-groups

basically, if you want to be able to do:

cargo make server start
cargo make server stop
cargo make client start
cargo make client stop

you can define it as follows:

[tasks.server]
private = false
extend = "subcommand"
env = { "SUBCOMMAND_PREFIX" = "server" }

[tasks.client]
private = false
extend = "subcommand"
env = { "SUBCOMMAND_PREFIX" = "client" }

[tasks.subcommand]
private = true
script = '''
#!@duckscript

cm_run_task ${SUBCOMMAND_PREFIX}_${1}
'''

[tasks.server_start]
private = true
command = "echo"
args = ["starting s…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@sagiegurari
Comment options

@john-michaelburke
Comment options

Comment options

You must be logged in to vote
1 reply
@john-michaelburke
Comment options

Answer selected by john-michaelburke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants