44use clap:: Command ;
55use clap:: builder:: StyledStr ;
66
7- use crate :: ui;
7+ use crate :: ui:: style :: { HEADER , LITERAL , PLACEHOLDER } ;
88
99/// Sets our custom help messages.
1010pub fn set ( cmd : Command ) -> Command {
@@ -18,6 +18,8 @@ pub fn set(cmd: Command) -> Command {
1818 scmd. override_help ( format_msg ( ) )
1919 } else if name == "clippy" {
2020 scmd. override_help ( clippy_msg ( ) )
21+ } else if name == "copyright" {
22+ scmd. override_help ( copyright_msg ( ) )
2123 } else {
2224 panic ! ( "Sub-command '{name}' help message is not implemented" ) ;
2325 }
@@ -26,22 +28,23 @@ pub fn set(cmd: Command) -> Command {
2628
2729/// Returns the main help message.
2830pub fn root_msg ( ) -> StyledStr {
29- let ( gb , cb , bb ) = ui :: styles ( ) ;
31+ let ( h , l , p ) = ( HEADER , LITERAL , PLACEHOLDER ) ;
3032 let help = format ! (
3133 "\
3234 Prepare Rust projects for greatness.
3335
34- {gb }Usage:{gb :#} {cb }prep{cb :#} {bb }[command] [options]{bb :#}
36+ {h }Usage:{h :#} {l }prep{l :#} {p }[command] [options]{p :#}
3537
36- {gb}Commands:{gb:#}
37- {cb} ci {cb:#}Verify for CI.
38- {cb}clp clippy {cb:#}Analyze with Clippy.
39- {cb}fmt format {cb:#}Format with rustfmt.
40- {cb} help {cb:#}Print help for the provided command.
38+ {h}Commands:{h:#}
39+ {l} ci {l:#}Verify for CI.
40+ {l}clp clippy {l:#}Analyze with Clippy.
41+ {l} copyright {l:#}Verify copyright headers.
42+ {l}fmt format {l:#}Format with rustfmt.
43+ {l} help {l:#}Print help for the provided command.
4144
42- {gb }Options:{gb :#}
43- {cb }-h --help {cb :#}Print help for the provided command.
44- {cb }-V --version {cb :#}Print version information.
45+ {h }Options:{h :#}
46+ {l }-h --help {l :#}Print help for the provided command.
47+ {l }-V --version {l :#}Print version information.
4548"
4649 ) ;
4750
@@ -50,64 +53,80 @@ Prepare Rust projects for greatness.
5053
5154/// Returns the `ci` help message.
5255fn ci_msg ( ) -> StyledStr {
53- let ( gb, cb, bb) = ui:: styles ( ) ;
54-
56+ let ( h, l, p) = ( HEADER , LITERAL , PLACEHOLDER ) ;
5557 let help = format ! (
5658 "\
5759 Verify the Rust workspace for CI.
5860
59- {gb }Usage:{gb :#} {cb }prep ci{cb :#} {bb }[options]{bb :#}
61+ {h }Usage:{h :#} {l }prep ci{l :#} {p }[options]{p :#}
6062
61- {gb }Options:{gb :#}
62- {cb }-e --extended {cb :#}Run the extended verification suite.
63- ···· · ·····Good idea for actual CI, rarely useful for local prep.
64- {cb }-n --no-fail-fast {cb :#}Keep going when encountering an error.
65- {cb }-h --help {cb :#}Print this help message.
63+ {h }Options:{h :#}
64+ {l }-e --extended {l :#}Run the extended verification suite.
65+ ··· ·····Good idea for actual CI, rarely useful for local prep.
66+ {l }-n --no-fail-fast {l :#}Keep going when encountering an error.
67+ {l }-h --help {l :#}Print this help message.
6668"
6769 )
6870 . replace ( "·" , "" ) ;
6971
7072 StyledStr :: from ( help)
7173}
7274
73- /// Returns the `format` help message.
74- fn format_msg ( ) -> StyledStr {
75- let ( gb, cb, bb) = ui:: styles ( ) ;
75+ /// Returns the `clippy` help message.
76+ fn clippy_msg ( ) -> StyledStr {
77+ let ( h, l, p) = ( HEADER , LITERAL , PLACEHOLDER ) ;
78+ let help = format ! (
79+ "\
80+ Analyze the Rust workspace with Clippy.
81+
82+ {h}Usage:{h:#} {l}prep clp{l:#} {p}[options]{p:#}
83+ ··· ····· {l}prep clippy{l:#} {p}[options]{p:#}
7684
85+ {h}Options:{h:#}
86+ {l}-c --crates <val> {l:#}Target specified crates. Possible values:
87+ ··· ·····{p}main{p:#} -> Binaries and the main library. (default)
88+ ··· ·····{p}aux{p:#} -> Examples, tests, and benches.
89+ ··· ·····{p}all{p:#} -> All of the above.
90+ {l}-s --strict {l:#}Treat warnings as errors.
91+ {l}-h --help {l:#}Print this help message.
92+ "
93+ )
94+ . replace ( "·" , "" ) ;
95+
96+ StyledStr :: from ( help)
97+ }
98+
99+ /// Returns the `copyright` help message.
100+ fn copyright_msg ( ) -> StyledStr {
101+ let ( h, l) = ( HEADER , LITERAL ) ;
77102 let help = format ! (
78103 "\
79- Format the Rust workspace with rustfmt .
104+ Verify that all Rust source files have the correct copyright header .
80105
81- {gb}Usage:{gb:#} {cb}prep fmt{cb:#} {bb}[options]{bb:#}
82- ···· ······ {cb}prep format{cb:#} {bb}[options]{bb:#}
106+ {h}Usage:{h:#} {l}prep copyright{l:#}
83107
84- {gb}Options:{gb:#}
85- {cb}-c --check {cb:#}Verify that the workspace is already formatted.
86- {cb}-h --help {cb:#}Print this help message.
108+ {h}Options:{h:#}
109+ {l}-h --help {l:#}Print this help message.
87110"
88111 )
89112 . replace ( "·" , "" ) ;
90113
91114 StyledStr :: from ( help)
92115}
93116
94- /// Returns the `clippy ` help message.
95- fn clippy_msg ( ) -> StyledStr {
96- let ( gb , cb , bb ) = ui :: styles ( ) ;
117+ /// Returns the `format ` help message.
118+ fn format_msg ( ) -> StyledStr {
119+ let ( h , l , p ) = ( HEADER , LITERAL , PLACEHOLDER ) ;
97120 let help = format ! (
98121 "\
99- Analyze the Rust workspace with Clippy .
122+ Format the Rust workspace with rustfmt .
100123
101- {gb }Usage:{gb :#} {cb }prep clp{cb :#} {bb }[options]{bb :#}
102- ···· ······ {cb }prep clippy{cb :#} {bb }[options]{bb :#}
124+ {h }Usage:{h :#} {l }prep fmt{l :#} {p }[options]{p :#}
125+ ··· ····· {l }prep format{l :#} {p }[options]{p :#}
103126
104- {gb}Options:{gb:#}
105- {cb}-c --crates <val> {cb:#}Target specified crates. Possible values:
106- ···· ······{bb}main{bb:#} -> Binaries and the main library. (default)
107- ···· ······{bb}aux{bb:#} -> Examples, tests, and benches.
108- ···· ······{bb}all{bb:#} -> All of the above.
109- {cb}-s --strict {cb:#}Treat warnings as errors.
110- {cb}-h --help {cb:#}Print this help message.
127+ {h}Options:{h:#}
128+ {l}-c --check {l:#}Verify that the workspace is already formatted.
129+ {l}-h --help {l:#}Print this help message.
111130"
112131 )
113132 . replace ( "·" , "" ) ;
0 commit comments