That’s it! The CLI is complete. Its a fairly small CLI that outputs templated files into a specific directory.
This is a great starter project because its something you can write to start scaffolding your own files for your own projects, personal or work related. Most importantly, you can use a CLI tool like this without converting your entire company to use Rust.
There are a few things to do to wrap it up.
First, make sure you remove all remaining dbg!
macros or anything else producing output. Conventionally, successful CLI programs often don’t produce any output.
create_new
Also, every time we’ve run our CLI so far, it has overwritten the last file we wrote without us noticing (or, if you’re really attentive, maybe you already noticed. congrats!).
There is an up and coming API called [create_new](https://doc.rust-lang.org/std/fs/struct.File.html#method.create_new)
that can fail if the file already exists, but the function is nightly only and hasn’t been stabilized as of the recording of this video.
If you want to try to get this to work, you will have to install a nightly toolchain using Rustup, and then use Cargo’s built-in support to run the app using that nightly toolchain.
rustup toolchain install nightly
cargo +nightly run
Otherwise the create_new
docs hold all the information you need to make this function work. See how far you can get, and feel free to ask questions in discord.