File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ Usage:
118
118
Common options:
119
119
-h, --help Print this message
120
120
--features Features to compile for the package
121
+ -V, --version Print version info and exit
121
122
122
123
Other options are the same as `cargo rustc`.
123
124
@@ -146,17 +147,22 @@ pub fn main() {
146
147
if env:: var ( "CLIPPY_DOGFOOD" ) . map ( |_| true ) . unwrap_or ( false ) {
147
148
panic ! ( "yummy" ) ;
148
149
}
150
+
151
+ // Check for version and help flags even when invoked as 'cargo-clippy'
152
+ if std:: env:: args ( ) . any ( |a| a == "--help" || a == "-h" ) {
153
+ show_help ( ) ;
154
+ return ;
155
+ }
156
+ if std:: env:: args ( ) . any ( |a| a == "--version" || a == "-V" ) {
157
+ println ! ( "{}" , env!( "CARGO_PKG_VERSION" ) ) ;
158
+ return ;
159
+ }
149
160
150
161
let dep_path = env:: current_dir ( ) . expect ( "current dir is not readable" ) . join ( "target" ) . join ( "debug" ) . join ( "deps" ) ;
151
162
152
163
if let Some ( "clippy" ) = std:: env:: args ( ) . nth ( 1 ) . as_ref ( ) . map ( AsRef :: as_ref) {
153
164
// this arm is executed on the initial call to `cargo clippy`
154
165
155
- if std:: env:: args ( ) . any ( |a| a == "--help" || a == "-h" ) {
156
- show_help ( ) ;
157
- return ;
158
- }
159
-
160
166
let manifest_path_arg = std:: env:: args ( ) . skip ( 2 ) . find ( |val| val. starts_with ( "--manifest-path=" ) ) ;
161
167
162
168
let mut metadata = cargo:: metadata ( manifest_path_arg. as_ref ( ) . map ( AsRef :: as_ref) ) . expect ( "could not obtain cargo metadata" ) ;
You can’t perform that action at this time.
0 commit comments