Cargo Project Scripts

What is the most idomatic way to create a project scripts in cargo projects? Node js has scripts in their package.json and we can run npm run <the_script_name> to run it. Does cargo has similar feature? For example, I want to perform some operation in my project such running the test and put the coverage in the README.md, or downloading a text file and put it in my repo.

I have 2 alternatives, but I'm looking for other option, if there is any:

  1. Using cargo build script: but,I don't think this is appropriate since it's not technically building my app, and I want to run it manually, not when I'm building my app.
  2. Using binary crate. This is one way, but binary create feels like I'm writing shippable program, not for project-related tooling.

cargo-xtask may be able to do what you want. Cargo itself currently doesn't have any built in support other than binary crates as you noted.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.