11mod check;
2+ mod fmt;
23mod metadata;
34mod permutation;
45mod process;
56mod test;
67mod util;
78
8- use std:: fmt;
99use std:: fmt:: { Display , Formatter } ;
10- use std:: process:: Command ;
11- use std:: time:: Duration ;
1210
1311use anyhow:: Result ;
1412use clap:: { Args , Subcommand , ValueEnum } ;
1513use strum:: EnumIter ;
1614
1715use self :: check:: { Check , Tools } ;
16+ use self :: fmt:: Fmt ;
1817use self :: permutation:: Toolchain ;
1918use self :: test:: Test ;
2019use self :: util:: ToolchainParser ;
21- use crate :: command :: { self , CargoCommand } ;
22- use crate :: { FmtTool , FmtTools } ;
20+ use crate :: FmtTools ;
21+ use crate :: command :: CargoCommand ;
2322
2423#[ derive( Subcommand ) ]
2524pub enum Client {
@@ -31,17 +30,13 @@ pub enum Client {
3130 #[ command( flatten) ]
3231 test : Test ,
3332 } ,
34- Fmt {
35- #[ arg( long, value_delimiter = ',' , default_value = FmtTools :: default_arg( ) ) ]
36- tools : Vec < FmtTools > ,
37- } ,
33+ Fmt ( Fmt ) ,
3834 Build {
3935 #[ command( flatten) ]
4036 args : ClientArgs ,
4137 } ,
4238 Check ( Check ) ,
4339 Test ( Test ) ,
44- Audit ,
4540}
4641
4742#[ derive( Args , Clone ) ]
@@ -56,9 +51,7 @@ pub struct ClientArgs {
5651
5752impl Client {
5853 pub fn fmt ( ) -> Self {
59- Self :: Fmt {
60- tools : vec ! [ FmtTools :: default ( ) ] ,
61- }
54+ Self :: Fmt ( Fmt :: default ( ) )
6255 }
6356
6457 pub fn build ( all : bool ) -> Self {
@@ -96,7 +89,7 @@ impl Client {
9689 check_tools,
9790 test,
9891 } => {
99- Self :: Fmt { tools : fmt_tools } . execute ( verbose) ?;
92+ Self :: Fmt ( Fmt :: new ( fmt_tools) ) . execute ( verbose) ?;
10093 println ! ( "-------------------------" ) ;
10194 println ! ( ) ;
10295 Self :: Build {
@@ -112,35 +105,7 @@ impl Client {
112105
113106 Ok ( ( ) )
114107 }
115- Self :: Fmt { tools } => {
116- let tools = FmtTool :: from_tools ( tools) ?;
117- let mut duration = Duration :: ZERO ;
118-
119- for tool in tools {
120- match tool {
121- FmtTool :: Rustfmt => {
122- let mut command = Command :: new ( "cargo" ) ;
123- command. current_dir ( "../client" ) . args ( [ "+nightly" , "fmt" ] ) ;
124- duration += command:: run ( "Rustfmt" , command, verbose) ?;
125- }
126- FmtTool :: Tombi => {
127- let mut command = Command :: new ( "tombi" ) ;
128- command. current_dir ( "../client" ) . args ( [ "format" , "." ] ) ;
129- duration += command:: run ( "Tombi Format" , command, verbose) ?;
130- }
131- FmtTool :: Prettier => {
132- let mut command = Command :: new ( "prettier" ) ;
133- command. current_dir ( ".." ) . args ( [ "client" , "-w" ] ) ;
134- duration += command:: run ( "Prettier" , command, verbose) ?;
135- }
136- }
137- }
138-
139- println ! ( "-------------------------" ) ;
140- println ! ( "Total Time: {:.2}s" , duration. as_secs_f32( ) ) ;
141-
142- Ok ( ( ) )
143- }
108+ Self :: Fmt ( fmt) => fmt. execute ( verbose) ,
144109 Self :: Build { args } => {
145110 let command = CargoCommand {
146111 title : "Build" ,
@@ -157,16 +122,6 @@ impl Client {
157122 }
158123 Self :: Check ( check) => check. execute ( verbose) ,
159124 Self :: Test ( test) => test. execute ( verbose) ,
160- Self :: Audit => {
161- let mut command = Command :: new ( "cargo" ) ;
162- command. current_dir ( "../client" ) . arg ( "audit" ) ;
163- let duration = command:: run ( "RustSec" , command, verbose) ?;
164-
165- println ! ( "-------------------------" ) ;
166- println ! ( "Total Time: {:.2}s" , duration. as_secs_f32( ) ) ;
167-
168- Ok ( ( ) )
169- }
170125 }
171126 }
172127}
@@ -249,7 +204,7 @@ impl Target {
249204}
250205
251206impl Display for Target {
252- fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
207+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std :: fmt:: Result {
253208 match self {
254209 Self :: Wasm32 => f. write_str ( "Wasm32" ) ,
255210 Self :: Wasm64 => f. write_str ( "Wasm64" ) ,
@@ -274,7 +229,7 @@ impl TargetFeature {
274229}
275230
276231impl Display for TargetFeature {
277- fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
232+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std :: fmt:: Result {
278233 match self {
279234 Self :: Default => Ok ( ( ) ) ,
280235 Self :: Atomics => f. write_str ( "Atomics" ) ,
0 commit comments