Skip to content

Add '--version' flag and allow version and help flags when called as 'cargo-clippy' #1328

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

Merged
merged 3 commits into from Nov 9, 2016
Merged

Conversation

ghost
Copy link

@ghost ghost commented Nov 8, 2016

This makes it easier to integrate 'cargo clippy' into other tools.
(Or at least makes it possible to reason about the capabilities of the tool based on its version).

metadata
} else {
let _ = io::stderr().write_fmt(format_args!("error: Could not obtain cargo metadata."));
process::exit(101);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have a pretty random policy with panics vs process::exit, so I guess this is fine. What's the reason for this change though?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, actually this was just because I dislike seeing stack traces when running tools. And I'd just done something similar for 'cargo-check' so I thought "might as well".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a million other cases where cargo clippy can panic. I think we should do a clean refactor of the main function to use Result based error handling and then have a single location that calls process::exit but that's for a different PR :)

println!("{}", env!("CARGO_PKG_VERSION"));
}

#[cfg_attr(feature = "cargo-clippy", allow(print_stdout))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this attribute added? And why only under the cargo-clippy feature?

@ghost
Copy link
Author

ghost commented Nov 9, 2016

It was just an artifact from when I was trying to please the dogfood test. Removed now.

@oli-obk oli-obk merged commit 2cfe1e7 into rust-lang:master Nov 9, 2016
@oli-obk
Copy link
Contributor

oli-obk commented Nov 9, 2016

thanks!

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.

1 participant