Describe the problem you are trying to solve
Make it easier to add examples to a project.
Describe the solution you'd like
I would like a basic scaffold of an example, probably with just an empty main method when I run cargo new --example <name>.
So if I were to run cargo new --example celeryman, what would be different code-wise from running cargo new celeryman?
I wonder if you might be referring to scaffolding, and are hoping to get some Yeoman-esque functionality in the cargo tool?
Probably only that it lands in "examples" folder. I'm not looking for much.
Just a little help for the people who's new, and don't know how the
examples should look. For instance, I'm making a library, and had to go
look up how a main method in rust looks, cause I didn't remember. Then, I
didn't know if I could do examples/
examples/run --example, I would say
it fits together, and I sort of expected it to work.
On Wed, May 15, 2019, 06:00 Jesse Lawson notifications@github.com wrote:
So if I were to run cargo new --example celeryman, what would be
different code-wise from running cargo new celeryman?I wonder if you might be referring to scaffolding, and are hoping to get
some Yeoman-esque functionality in the cargo tool?—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/rust-lang/cargo/issues/6939?email_source=notifications&email_token=AAA3NTWMLCW6SBZQTFARDDTPVODE3A5CNFSM4HMZMRNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVNN36Y#issuecomment-492494331,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAA3NTUISZPKRPN22U4NFMDPVODE3ANCNFSM4HMZMRNA
.
It would be nice to have this feature.
The command should generate:
examples folder, if one doesn't exist alreadyexamples/{name} subfolderexamples/{name}/main.rs file, potentially with a hello-world program, much like with the standard cargo new commandcargo.toml file of the root project.It would help if the docs for cargo run --example said more than 'Runs the specified example' here. That's just annoying. I got there by searching the web, but so far haven't found an explanation of what it really means and how to create an example.
I can just copy stuff from an [cough] example crate and fiddle until it works, but it would help to have a pointer to an explanation in the docs.
Yeah, there's also that. The only reason I know about the feature is because I noticed a large-ish project using it and I reverse engineered it. The docs weren't of much help.
Most helpful comment
It would be nice to have this feature.
The command should generate:
examplesfolder, if one doesn't exist alreadyexamples/{name}subfolderexamples/{name}/main.rsfile, potentially with a hello-world program, much like with the standardcargo newcommandcargo.tomlfile of the root project.