Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd --lib and status message for completion #2921
Conversation
rust-highfive
assigned
alexcrichton
Jul 26, 2016
This comment has been minimized.
This comment has been minimized.
rust-highfive
commented
Jul 26, 2016
|
(rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
|
Hm, when we made cargo, we assumed the opposite. What's the basis here? On Jul 26, 2016, 15:02 -0700, Rust highfive robot notifications@github.com, wrote:
|
This comment has been minimized.
This comment has been minimized.
|
Also, while Cargo is technically nightly, we've considered the CLI pretty On Tue, Jul 26, 2016 at 6:29 PM, Steve Klabnik steve@steveklabnik.com
|
This comment has been minimized.
This comment has been minimized.
|
@steveklabnik - Cargo is at "0.13.0-nightly (dc12479 2016-07-22)", so we're still pre-1.0. I agree that we don't want to go breaking things willy-nilly... It looks like the hunch that most people would make libraries doesn't seem to play out from the results we're seeing. The 2016 survey puts "contributes to crates.io" as a minority of our users (roughly 550 of the 2000 active Rust users in the survey). There's another intuition that if you're trying to make a library, you already have a bit of Rust experience under your belt. You know how to look up documentation and how to set up additional settings. I'd argue even into your first few days as a Rust developer you may not have created a library yet, but likely would have created a few small apps. If the minority of users create libraries, and we're making users go down less ergonomic paths because of it, this seems like a good reason to change the default. |
This comment has been minimized.
This comment has been minimized.
|
One possibility for sequencing this as well is to add the I agree with @steveklabnik that despite cargo being "pre 1.0" it's basically defacto stable in many respects. I'm not too worried about breakage here, but it may be best to head it off by moving slowly. I don't personally recall the exact reasons why we chose libraries as the default, but I'm sympathetic to the data just being the other way around so don't mind changing on that basis. |
alexcrichton
reviewed
Jul 27, 2016
| } | ||
| else { | ||
| flag_bin | ||
| }; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jul 27, 2016
Member
Oh I see, yeah let's just pass through these flags as-is and have the "default logic" kick in during the implementation below
This comment has been minimized.
This comment has been minimized.
|
cc @rust-lang/tools, thoughts about changing the default? |
This comment has been minimized.
This comment has been minimized.
|
+1 on adding --lib, +0.5 on changing the default - It annoys me personally, I nearly always want --bin, but Cargo is de facto pretty stable, so we should do this gently rather than flicking the switch. In addition to Alex's suggestion, could we warn when doing |
This comment has been minimized.
This comment has been minimized.
|
I think I agree that I'm unsure the best way to proceed, or if the breakage is worth it. Another way we could transition is by temporarily changing |
This comment has been minimized.
This comment has been minimized.
|
So it sounds like we're leaning towards making it the default but with caution. Maybe we can switch the default but also just add a general result message for any new/init? Something like:
|
This comment has been minimized.
This comment has been minimized.
I think the motivation for this PR from @jonathandturner was to simplify the newbie experience with just
This... seems like a great idea! @jonathandturner what do you think of this? The idea of a status message also seems fine to me, it's arguably just missing today. |
This comment has been minimized.
This comment has been minimized.
|
I lean towards the status message. Putting both in works on one level, since it doesn't have a preference. But what I'm trying to fix is that there's a happy path for users, especially new users. If a new user types "cargo new foo", they'll end up getting more than they have today that they need to read and understand. I'd rather have a simple starter template. |
This comment has been minimized.
This comment has been minimized.
|
I'm comfortable with adding |
jonathandturner
force-pushed the
jonathandturner:bin_by_default
branch
from
3d6b8f5
to
fcd3b95
Jul 28, 2016
This comment has been minimized.
This comment has been minimized.
|
Switched to using @wycats/@nrc's suggestion, so I now warn if you do a cargo new without a target. Default is back to --lib. I also added a status message for successful completion of a new/init. |
jonathandturner
force-pushed the
jonathandturner:bin_by_default
branch
from
fcd3b95
to
de00a9c
Jul 29, 2016
jonathandturner
changed the title
Add --lib and default new/init to --bin (apps)
Add --lib and status message for completion
Jul 29, 2016
This comment has been minimized.
This comment has been minimized.
|
Started a thread here: https://internals.rust-lang.org/t/should-cargo-new-default-to-applications/3772 to see if we should change the default. For the time being, leaving the PR as a simple "add --lib and add a status message". |
alexcrichton
reviewed
Jul 29, 2016
|
|
||
| try!(config.shell().status("Created", format!("{} project", | ||
| if is_lib { "library" } | ||
| else {"binary (application)"}))); |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jul 29, 2016
Member
Can this be pushed into ops to deduplicate betwen here and new? (same with the if block above
This comment has been minimized.
This comment has been minimized.
jonathandturner
Jul 29, 2016
•
Author
The messages are different between init and new, so I'm not sure how much that would buy us.
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jul 29, 2016
Member
Oh ok, in that case maybe it could be pushed down into the init and new functions? (would be good to deduplicate the if above in any case)
jonathandturner
force-pushed the
jonathandturner:bin_by_default
branch
from
de00a9c
to
a882abe
Jul 29, 2016
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton Fixed and squished. Defaulting now happens in a constructor that's shared by both functions. |
This comment has been minimized.
This comment has been minimized.
|
Ah right one last thing is could you add a test where both |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton - done. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Jul 29, 2016
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit a0a7752
into
rust-lang:master
Jul 30, 2016
alexcrichton
added
the
relnotes
label
Jul 30, 2016
This comment has been minimized.
This comment has been minimized.
SoniEx2
commented
Oct 4, 2016
•
|
Why can't specify both bin and lib? You /can/ have both lib.rs and main.rs... (Should I be opening a new issue instead of hijacking a merged PR?) |
This comment has been minimized.
This comment has been minimized.
|
@SoniEx2 ah yeah in general you should be able to combine any number of |
jonathandturner commentedJul 26, 2016
•
edited
This PR adds a --lib flag for creating a library with new/init. It also adds a status message for a successful completion.