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 --name suggestion for cargo new #8675

Merged
merged 5 commits into from
Sep 10, 2020
Merged

Conversation

weihanglo
Copy link
Member

Resolves #8613

Since check_name have already got a parameter to show name help, I reuse the logic and sync the behavior between cargo init and cargo new. The divergence seems to be intentionally made in #7959:

...Only print the --name suggestion for cargo init.

Feel free to discuss.

@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 4, 2020
@weihanglo
Copy link
Member Author

r? @Eh2406 Since @Eh2406 are involved in previous discussion.

Also cc @ehuss as the original author of --name suggestion.

@rust-highfive rust-highfive assigned Eh2406 and unassigned alexcrichton Sep 4, 2020
@weihanglo weihanglo changed the title Fix/name help Add --name suggestion for cargo new Sep 4, 2020
@joshtriplett
Copy link
Member

I feel like suggesting --name is a little unusual here. The common case doesn't seem likely to be "I want to create an unusual directory name but name the project something different"; that's not a pattern we should actively encourage. The common case is likely to be "Oh, I should use a different directory name". Steering people towards --name doesn't seem like the right answer.

@Eh2406
Copy link
Contributor

Eh2406 commented Sep 9, 2020

How does something like "if you need the directory name to not match the project name consider the --name flag" sound?

@joshtriplett
Copy link
Member

joshtriplett commented Sep 9, 2020 via email

@Eh2406
Copy link
Contributor

Eh2406 commented Sep 10, 2020

@ehuss how does this seam to you?

@weihanglo
Copy link
Member Author

weihanglo commented Sep 10, 2020

Just rephrase as "If you need a crate name to not match the directory name, consider using --name flag." So the whole message would be something like

[ERROR] invalid character `¼` in crate name: `a¼`, characters must be Unicode XID characters (numbers, `-`, `_`, or most letters)
If you need a crate name to not match the directory name, consider using --name flag.

I did not choose the suggestion approach mentioned in this comment because in real world the situation is more complex and may lead to suggest another invalid name.

@ehuss
Copy link
Contributor

ehuss commented Sep 10, 2020

@ehuss how does this seam to you?

The most recent update looks good to me!

@Eh2406
Copy link
Contributor

Eh2406 commented Sep 10, 2020

Sounds like the team is on board!
Thank you @weihanglo!
@bors r+

@bors
Copy link
Contributor

bors commented Sep 10, 2020

📌 Commit c6fcb0e has been approved by Eh2406

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 10, 2020
@bors
Copy link
Contributor

bors commented Sep 10, 2020

⌛ Testing commit c6fcb0e with merge 2c10f26...

@bors
Copy link
Contributor

bors commented Sep 10, 2020

☀️ Test successful - checks-actions
Approved by: Eh2406
Pushing 2c10f26 to master...

@bors bors merged commit 2c10f26 into rust-lang:master Sep 10, 2020
@weihanglo weihanglo deleted the fix/name-help branch September 11, 2020 00:28
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 15, 2020
Update cargo

6 commits in 875e0123259b0b6299903fe4aea0a12ecde9324f..8777a6b1e8834899f51b7e09cc9b8d85b2417110
2020-09-08 20:17:21 +0000 to 2020-09-15 19:11:03 +0000
- updated yank error message (rust-lang/cargo#8697)
- Fix non-determinism with new feature resolver. (rust-lang/cargo#8701)
- Display formatted output for JSON diffing in tests. (rust-lang/cargo#8692)
- Add --name suggestion for cargo new (rust-lang/cargo#8675)
- Sweep unrelated message from unnecessary workspace infromation (rust-lang/cargo#8681)
- Docs: Make it more clear we have two types of workspaces (rust-lang/cargo#8666)
@ehuss ehuss added this to the 1.48.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't Scaffold A New Project With Name Beginning With Number?
7 participants