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

Move command prelude into main library #6335

Merged
merged 1 commit into from
Nov 20, 2018

Conversation

bossmc
Copy link
Contributor

@bossmc bossmc commented Nov 19, 2018

When writing cargo sub-commands, it would be really useful to have access to these pre-built command line argument creates/parsers.

In a perfect world, I'd also move the contents of src/bin/cargo/{cli.rs, main.rs, command/mod.rs} that aren't specific to the built-in commands, but that's more complicated than this simple move of a module.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@dwijnand
Copy link
Member

My concern is that isn't stable API. None of the cargo crate is, in fact, so I don't know if it's net-positive or net-negative to expose more API in it.

@bossmc
Copy link
Contributor Author

bossmc commented Nov 20, 2018

A fair concern, but there are multiple cargo plugins that, today, are re-implementing some sub-set of the correct interface. This makes implementing a cargo plugin more tedious, and makes the end user experience worse as each command's CLI arguments are different.

Even if this API is not stable, having "this is what cargo does, if you want to do the same thing here are some pre-canned helper functions" seems like a win.

In fact, having this interface break when the command line arguments for (say) cargo build change is possibly a good thing, as other tools that mimic cargo build's interface probably want to take the change (along with the associated implementation/function) to match.

@dwijnand
Copy link
Member

I forgot to express in my previous comment that while the current API isn't stable I believe we should start stabilising some of cargo's programmatic API.

Even if this API is not stable, having "this is what cargo does, if you want to do the same thing here are some pre-canned helper functions" seems like a win.

How's it a win if the helper functions aren't stable?

Btw, @alexcrichton, is it possible to do a crater run on all the crates that are cargo subcommands? In order to see what the impact a breaking change might have on the subcommand ecosystem.

@alexcrichton
Copy link
Member

I'd personally be ok merging this, I think it's good to develop idioms over time of how to write idiomatic subcommands of Cargo, and this can help quite a lot!

We publish a new major version of Cargo to crates.io on all releases, so I'm not too worried about compatibility or breaking changes. For that reason I also think crater wouldn't turn up much because all historical crates will continue to work as a they won't pick up the new major version.

@dwijnand
Copy link
Member

Oh, I see. That's really smart.

@bors: r+

@bors
Copy link
Collaborator

bors commented Nov 20, 2018

📋 Looks like this PR is still in progress, ignoring approval.

Hint: Remove WIP from this PR's title when it is ready for review.

@dwijnand
Copy link
Member

This bot is smart too.

@bossmc
Copy link
Contributor Author

bossmc commented Nov 20, 2018

Well played bot - I've left this as WIP because I'm not sure whether to do the cli.rs changes, but lets move in small steps for now.

@bossmc bossmc changed the title WIP: Move command prelude into main library Move command prelude into main library Nov 20, 2018
@dwijnand
Copy link
Member

@bors: r+

@bors
Copy link
Collaborator

bors commented Nov 20, 2018

📌 Commit 077a31a has been approved by dwijnand

@bors
Copy link
Collaborator

bors commented Nov 20, 2018

⌛ Testing commit 077a31a with merge e192fdf...

bors added a commit that referenced this pull request Nov 20, 2018
Move command prelude into main library

When writing cargo sub-commands, it would be really useful to have access to these pre-built command line argument creates/parsers.

In a perfect world, I'd also move the contents of `src/bin/cargo/{cli.rs, main.rs, command/mod.rs}` that aren't specific to the built-in commands, but that's more complicated than this simple move of a module.
@bors
Copy link
Collaborator

bors commented Nov 20, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: dwijnand
Pushing e192fdf to master...

@bors bors merged commit 077a31a into rust-lang:master Nov 20, 2018
@bossmc bossmc deleted the cli-in-library branch November 20, 2018 18:31
kennytm added a commit to kennytm/rust that referenced this pull request Nov 27, 2018
Update cargo

14 commits in b3d0b2e545b61d4cd08096911724b7d49d213f73..1ff5975b96b3d395bb962394596998dfb485f793
2018-11-15 19:13:04 +0000 to 2018-11-25 14:59:12 +0000
- Intern SourceId (rust-lang/cargo#6342)
- Tweak Layout to allow for non json file targets with internal "." (rust-lang/cargo#6255)
- Correct Target Directory command-line option (rust-lang/cargo#6343)
- Persistent data structures by im-rs (rust-lang/cargo#6336)
- Move command prelude into main library (rust-lang/cargo#6335)
- Distinguish custom build invocations (rust-lang/cargo#6331)
- Allow crate_type=bin examples to run (rust-lang/cargo#6330)
- Make verify-project honour unstable features (rust-lang/cargo#6326)
- Make autodiscovery disable inferred targets (rust-lang/cargo#6329)
- Add `c` alias for `check` (rust-lang/cargo#6218)
- Allow user aliases to override built-in aliases (rust-lang/cargo#6259)
- Fix renaming directory project using build scripts with cross-compiling. (rust-lang/cargo#6328)
- Fix add_plugin_deps-related tests. (rust-lang/cargo#6327)
- Add a glossary. (rust-lang/cargo#6321)
kennytm added a commit to kennytm/rust that referenced this pull request Nov 30, 2018
Update cargo

14 commits in b3d0b2e545b61d4cd08096911724b7d49d213f73..1ff5975b96b3d395bb962394596998dfb485f793
2018-11-15 19:13:04 +0000 to 2018-11-25 14:59:12 +0000
- Intern SourceId (rust-lang/cargo#6342)
- Tweak Layout to allow for non json file targets with internal "." (rust-lang/cargo#6255)
- Correct Target Directory command-line option (rust-lang/cargo#6343)
- Persistent data structures by im-rs (rust-lang/cargo#6336)
- Move command prelude into main library (rust-lang/cargo#6335)
- Distinguish custom build invocations (rust-lang/cargo#6331)
- Allow crate_type=bin examples to run (rust-lang/cargo#6330)
- Make verify-project honour unstable features (rust-lang/cargo#6326)
- Make autodiscovery disable inferred targets (rust-lang/cargo#6329)
- Add `c` alias for `check` (rust-lang/cargo#6218)
- Allow user aliases to override built-in aliases (rust-lang/cargo#6259)
- Fix renaming directory project using build scripts with cross-compiling. (rust-lang/cargo#6328)
- Fix add_plugin_deps-related tests. (rust-lang/cargo#6327)
- Add a glossary. (rust-lang/cargo#6321)
Centril added a commit to Centril/rust that referenced this pull request Dec 1, 2018
Update cargo

14 commits in b3d0b2e545b61d4cd08096911724b7d49d213f73..1ff5975b96b3d395bb962394596998dfb485f793
2018-11-15 19:13:04 +0000 to 2018-11-25 14:59:12 +0000
- Intern SourceId (rust-lang/cargo#6342)
- Tweak Layout to allow for non json file targets with internal "." (rust-lang/cargo#6255)
- Correct Target Directory command-line option (rust-lang/cargo#6343)
- Persistent data structures by im-rs (rust-lang/cargo#6336)
- Move command prelude into main library (rust-lang/cargo#6335)
- Distinguish custom build invocations (rust-lang/cargo#6331)
- Allow crate_type=bin examples to run (rust-lang/cargo#6330)
- Make verify-project honour unstable features (rust-lang/cargo#6326)
- Make autodiscovery disable inferred targets (rust-lang/cargo#6329)
- Add `c` alias for `check` (rust-lang/cargo#6218)
- Allow user aliases to override built-in aliases (rust-lang/cargo#6259)
- Fix renaming directory project using build scripts with cross-compiling. (rust-lang/cargo#6328)
- Fix add_plugin_deps-related tests. (rust-lang/cargo#6327)
- Add a glossary. (rust-lang/cargo#6321)
bors added a commit to rust-lang/rust that referenced this pull request Dec 4, 2018
Update cargo, rls

26 commits in b3d0b2e545b61d4cd08096911724b7d49d213f73..5e85ba14aaa20f8133863373404cb0af69eeef2c
2018-11-15 19:13:04 +0000 to 2018-12-02 14:37:25 +0000
- ConflictStoreTrie: Faster filtered search (rust-lang/cargo#6366)
- Remove `cmake` as a requirement (rust-lang/cargo#6368)
- progress: display "Downloading 1 crate" instead of "Downloading 1 crates" (rust-lang/cargo#6369)
- Use expect over unwrap, for panic-in-panic aborts (rust-lang/cargo#6364)
- Switch to pretty_env_logger, under --features pretty-env-logger (rust-lang/cargo#6362)
- use allow-dirty option in `cargo package` to skip vcs checks (rust-lang/cargo#6280)
- remove clones made redundant by Intern PackageId (rust-lang/cargo#6352)
- docs: correct profile usage of `cargo test --release` (rust-lang/cargo#6345)
- Improve doc for `cargo install` (rust-lang/cargo#6354)
- Intern PackageId (rust-lang/cargo#6332)
- Clean only release artifacts if --release option is set (rust-lang/cargo#6349)
- remove clones made redundant by Intern SourceId (rust-lang/cargo#6347)
- Intern SourceId (rust-lang/cargo#6342)
- Tweak Layout to allow for non json file targets with internal "." (rust-lang/cargo#6255)
- Correct Target Directory command-line option (rust-lang/cargo#6343)
- Persistent data structures by im-rs (rust-lang/cargo#6336)
- Move command prelude into main library (rust-lang/cargo#6335)
- Distinguish custom build invocations (rust-lang/cargo#6331)
- Allow crate_type=bin examples to run (rust-lang/cargo#6330)
- Make verify-project honour unstable features (rust-lang/cargo#6326)
- Make autodiscovery disable inferred targets (rust-lang/cargo#6329)
- Add `c` alias for `check` (rust-lang/cargo#6218)
- Allow user aliases to override built-in aliases (rust-lang/cargo#6259)
- Fix renaming directory project using build scripts with cross-compiling. (rust-lang/cargo#6328)
- Fix add_plugin_deps-related tests. (rust-lang/cargo#6327)
- Add a glossary. (rust-lang/cargo#6321)
@ehuss ehuss added this to the 1.32.0 milestone Feb 6, 2022
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.

6 participants