}
macro_rules! print_usage {
- ($print: ident, $opts: ident, $reason: expr) => {{
+ ($print:ident, $opts:ident, $reason:expr) => {{
let msg = format!("{}\nusage: cargo fmt [options]", $reason);
$print!(
"{}\nThis utility formats all bin and lib files of the current crate using rustfmt. \
strategy: &CargoFmtStrategy,
) -> Result<ExitStatus, io::Error> {
let rustfmt_args = get_fmt_args();
- let targets = if rustfmt_args.iter().any(|s| s == "--dump-default-config") {
+ let targets = if rustfmt_args
+ .iter()
+ .any(|s| ["--print-config", "-h", "--help", "-V", "--version"].contains(&s.as_str()))
+ {
HashSet::new()
} else {
get_targets(strategy)?
pub enum CargoFmtStrategy {
/// Format every packages and dependencies.
All,
- /// Format pacakges that are specified by the command line argument.
+ /// Format packages that are specified by the command line argument.
Some(Vec<String>),
/// Format the root packages only.
Root,
fn get_cargo_metadata(manifest_path: Option<&Path>) -> Result<cargo_metadata::Metadata, io::Error> {
match cargo_metadata::metadata(manifest_path) {
Ok(metadata) => Ok(metadata),
- Err(..) => Err(io::Error::new(
- io::ErrorKind::Other,
- "`cargo manifest` failed.",
- )),
+ Err(error) => Err(io::Error::new(io::ErrorKind::Other, error.to_string())),
}
}