Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add force flag to allow user defined project name #69

Merged
merged 1 commit into from Aug 7, 2018

Conversation

toVersus
Copy link
Contributor

close: #66

Copy link
Contributor

@killercup killercup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I'm not really happy with --force as a name, because it's not clear what it enforces. Overwrite the directory if it already exists? Don't error when the template is broken? We should try to come up with a more specific name, and also add some help texts to the CLI --help stuff.

src/template.rs Outdated
let mut template = liquid::Object::new();
template.insert(
String::from("project-name"),
liquid::Value::scalar(&name.kebab_case()),
liquid::Value::scalar(&project_name),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI If project name is only used here you can also move it (scalar would otherwise clone the string internally)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for clarification! Project name is currently used only here, so I moved it!

src/main.rs Outdated
@@ -55,6 +55,8 @@ pub struct Args {
git: String,
#[structopt(long = "name")]
name: Option<String>,
#[structopt(long = "force", short = "f")]
force: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force? Force what? Force how?

Can you give this a more speaking name (like --exact-project-name) and/or add a doc comment (which will show up in --help)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to name this flag as --exact-project-name because I couldn't come up with more suitable name than you suggested, and also added help message.

.stdout(predicates::str::contains("Done!").from_utf8());

assert!(
dir.read("foobar-project/Cargo.toml")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait—this foobar-project here is in kebab case. Should the dir name also be the "raw" version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops...I fixed to apply user defined name to project directory.

@ashleygwilliams
Copy link
Collaborator

hey @toVersus thanks so much for this! seems like @killercup and i disagree about the name of the flag ;) i think i would still like to advocate --force as a flag you pass if you want "checks" and "corrections" that the program does to be skipped. i would be down with --exact-name or something like this also existing but to be honest it's a really long flag name.

assuming the flag was --force i would be happy to accept this PR. i'll need to chat with @killercup to sort the name situation... either way tho thank you @toVersus for this and i'll let you know soon exactly what the name should be <3

@toVersus
Copy link
Contributor Author

No problem! I know we should make careful decision about command line flags because it is hard to change its name even if someone complains of its unhandiness or unclearness. There are pros and cons for all choices, so I'm looking forward to see your conclusion :)

@ashleygwilliams
Copy link
Collaborator

hey @toVersus - thanks so much for your patience. after chatting with @killercup we think --force is fine :) if you make the changes to move it back to that we will gladly accept this!

@ashleygwilliams ashleygwilliams added this to the 0.2.0 milestone Aug 6, 2018
Copy link
Collaborator

@ashleygwilliams ashleygwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great! travis is failing because of cargo fmt weirdness so i'm gonna go ahead an merge instead of making you rebase in my fix for that stuff <3 thanks so much for your effort and patience!

@ashleygwilliams ashleygwilliams merged commit d7c624a into cargo-generate:master Aug 7, 2018
@toVersus toVersus deleted the force-flag branch August 8, 2018 07:42
@toVersus
Copy link
Contributor Author

toVersus commented Aug 8, 2018

Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

force flag
3 participants