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

cargo run in workspace needs to support --package argument #3529

Closed
matklad opened this issue Jan 11, 2017 · 7 comments · Fixed by #3691
Closed

cargo run in workspace needs to support --package argument #3529

matklad opened this issue Jan 11, 2017 · 7 comments · Fixed by #3691

Comments

@matklad
Copy link
Member

matklad commented Jan 11, 2017

No description provided.

@sanmai-NL
Copy link

Would it be most appropriate to make --package a general cargo argument instead of any subcommand's argument?

@alexcrichton
Copy link
Member

@sanmai-NL not necessarily, because commands like cargo install or cargo owner don't accept it.

@sunjay
Copy link
Member

sunjay commented Feb 12, 2017

Would love to see this! Even better would be if I could use the same run syntax as before but cargo would build and run the appropriate executable in my packages.

To explain further, let's say I had this structure:

src/
  bin/
    a.rs
    b.rs
    bb.rs

I used to be able to run:

cargo run --bin a
cargo run --bin b
cargo run --bin bb

With workspaces, I split that into two crates like this:

a/
  src/
    bin/
      a.rs
b/
  src/
    bin/
      b.rs
      bb.rs

It would be really nice if I could still run the same commands as above. The executable names are still the same and unique. They just belong to different crates in the same workspace now.

If the executables across crates aren't unique, then you should definitely make -p required, but otherwise it's way more ergonomic (and easier to remember) to just use the old commands.

It's the difference between cargo run -p b --bin b and cargo run --bin b.

@matklad
Copy link
Member Author

matklad commented Feb 13, 2017

@sunjay that's an interesting idea!

This also reminds me of #2941.

I think that the general problem is that we have boatload of things (packages, targets (which can be bin, lib, example (which now themselves can be bin or lib!)), items withing targets), and all these things use somewhat ad-hoc command-line flags for identification.

@alexcrichton I wonder if perhaps we want some kind of DSL to identify stuff, like various ways of referring to revision in git? The benefits would be

  • a universal way to identify anything (mainly for tools): no distinction between bin, lib, etc,

  • more convenient command line interface: run foo runs foo if there's only one match.

@alexcrichton
Copy link
Member

Yeah seems reasonable to me! I don't quite have an idea of what it would look like, but it'd be neat for tests as well I think

matklad added a commit to matklad/cargo that referenced this issue Feb 13, 2017
bors added a commit that referenced this issue Feb 14, 2017
cargo run supports --package argument

closes #3529
@sunjay
Copy link
Member

sunjay commented Feb 14, 2017

@alexcrichton now that this is implemented and closed? Should I open a new issue for what I suggested? I would still really like that feature.

@alexcrichton
Copy link
Member

@sunjay sure!

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

Successfully merging a pull request may close this issue.

4 participants