@@ -6,37 +6,14 @@ use std::env;
66use std:: path:: PathBuf ;
77use std:: process:: { self , Command } ;
88
9- const CARGO_CLIPPY_HELP : & str = "Checks a package to catch common mistakes and improve your Rust code.
10-
11- Usage:
12- cargo clippy [options] [--] [<opts>...]
13-
14- Common options:
15- --no-deps Run Clippy only on the given crate, without linting the dependencies
16- --fix Automatically apply lint suggestions. This flag implies `--no-deps` and `--all-targets`
17- -h, --help Print this message
18- -V, --version Print version info and exit
19- --explain LINT Print the documentation for a given lint
20-
21- For the other options see `cargo check --help`.
22-
23- To allow or deny a lint from the command line you can use `cargo clippy --`
24- with:
25-
26- -W --warn OPT Set lint warnings
27- -A --allow OPT Set lint allowed
28- -D --deny OPT Set lint denied
29- -F --forbid OPT Set lint forbidden
30-
31- You can use tool lints to allow or deny lints from your code, e.g.:
32-
33- #[allow(clippy::needless_lifetimes)]
34- " ;
9+ use anstream:: println;
3510
11+ #[ allow( clippy:: ignored_unit_patterns) ]
3612fn show_help ( ) {
37- println ! ( "{CARGO_CLIPPY_HELP}" ) ;
13+ println ! ( "{}" , help_message ( ) ) ;
3814}
3915
16+ #[ allow( clippy:: ignored_unit_patterns) ]
4017fn show_version ( ) {
4118 let version_info = rustc_tools_util:: get_version_info!( ) ;
4219 println ! ( "{version_info}" ) ;
@@ -168,6 +145,38 @@ where
168145 }
169146}
170147
148+ #[ must_use]
149+ pub fn help_message ( ) -> & ' static str {
150+ color_print:: cstr!(
151+ "Checks a package to catch common mistakes and improve your Rust code.
152+
153+ <green,bold>Usage</>:
154+ <cyan,bold>cargo clippy</> <cyan>[OPTIONS] [--] [<<ARGS>>...]</>
155+
156+ <green,bold>Common options:</>
157+ <cyan,bold>--no-deps</> Run Clippy only on the given crate, without linting the dependencies
158+ <cyan,bold>--fix</> Automatically apply lint suggestions. This flag implies <cyan>--no-deps</> and <cyan>--all-targets</>
159+ <cyan,bold>-h</>, <cyan,bold>--help</> Print this message
160+ <cyan,bold>-V</>, <cyan,bold>--version</> Print version info and exit
161+ <cyan,bold>--explain [LINT]</> Print the documentation for a given lint
162+
163+ See all options with <cyan,bold>cargo check --help</>.
164+
165+ <green,bold>Allowing / Denying lints</>
166+
167+ To allow or deny a lint from the command line you can use <cyan,bold>cargo clippy --</> with:
168+
169+ <cyan,bold>-W</> / <cyan,bold>--warn</> <cyan>[LINT]</> Set lint warnings
170+ <cyan,bold>-A</> / <cyan,bold>--allow</> <cyan>[LINT]</> Set lint allowed
171+ <cyan,bold>-D</> / <cyan,bold>--deny</> <cyan>[LINT]</> Set lint denied
172+ <cyan,bold>-F</> / <cyan,bold>--forbid</> <cyan>[LINT]</> Set lint forbidden
173+
174+ You can use tool lints to allow or deny lints from your code, e.g.:
175+
176+ <yellow,bold>#[allow(clippy::needless_lifetimes)]</>
177+ "
178+ )
179+ }
171180#[ cfg( test) ]
172181mod tests {
173182 use super :: ClippyCmd ;
0 commit comments