Skip to content

Running default cargo new #802

Answered by taurr
KarolStola asked this question in Q&A
Discussion options

You must be logged in to vote

if you want to run cargo new as part of the template, it can be done using Rhai as you describe, but its a bit cumbersome...

Command line:

cargo generate --allow-commands <template>

Then you need the actual template with the files you want to add, as well as a Rhai script that does:

let output = system::command("cargo", ["new", "additinal args..."]);

NOTE: if the external command (cargo new in this case) requires any kind of input it will fail! This is by design, and is a current known limitation.

... if it was me, considering that cargo new doesn't give you much to start with, I wouldn't bother! Just add the few files including the cargo new output to a small template and call it a day.…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sassman
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