Rustfmt: Support ‘cargo fmt -p PACKAGE1 -p PACKAGE2’ in a workspace with several packages

Created on 21 Dec 2016  Â·  6Comments  Â·  Source: rust-lang/rustfmt

cargo fmt should support -p/--package, like most other cargo subcommands, so that one can run cargo fmt -p PACKAGE1 -p PACKAGE2 in a Cargo workspace with several packages.

good first issue p-high

Most helpful comment

And may be cargo fmt --all to act on all the workspace members defined in the Cargo.toml

All 6 comments

And may be cargo fmt --all to act on all the workspace members defined in the Cargo.toml

This feature would be very useful to have as rustfmt is a must-have cargo plugin and not having support for workspaces is a major inconvenience.

I suspect this would be relatively easy to implement. The cargo fmt stuff is fairly self-contained (in https://github.com/rust-lang-nursery/rustfmt/blob/master/src/bin/cargo-fmt.rs) and IIUC, workspace support just comes down to specifying a different 'start file' for rustfmt.

If anyone wants to tackle this, I'd more than happy by answering questions or pointing towards parts of the system.

I am willing to implement this.

This has been fixed now 🎉

so that one can run cargo fmt -p PACKAGE1 -p PACKAGE2 in a Cargo workspace with several packages.

It is strange: $ cargo fmt -p package results

Invalid argument: package.
usage: cargo fmt [options]

Several combinations revealed the only accepting form: cargo fmt -ppackage o_O

P.S. version 0.3.8-nightly (346238f4 2018-02-04)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alatiera picture alatiera  Â·  4Comments

LPGhatguy picture LPGhatguy  Â·  3Comments

ratmice picture ratmice  Â·  3Comments

ozkriff picture ozkriff  Â·  4Comments

gnzlbg picture gnzlbg  Â·  3Comments