@@ -37,14 +37,6 @@ fn show_banner() {
3737 debug ! ( "codspeed v{}" , VERSION ) ;
3838}
3939
40- #[ derive( ValueEnum , Clone , Default , Debug , Serialize ) ]
41- #[ serde( rename_all = "lowercase" ) ]
42- pub enum RunnerMode {
43- #[ default]
44- Instrumentation ,
45- Walltime ,
46- }
47-
4840#[ derive( Args , Debug ) ]
4941pub struct RunArgs {
5042 /// The upload URL to use for uploading the results, useful for on-premises installations
@@ -87,8 +79,8 @@ pub struct RunArgs {
8779 #[ arg( long) ]
8880 pub mongo_uri_env_name : Option < String > ,
8981
90- #[ arg( long) ]
91- pub message_format : Option < String > ,
82+ #[ arg( long, hide = true ) ]
83+ pub message_format : Option < MessageFormat > ,
9284
9385 /// Only for debugging purposes, skips the upload of the results
9486 #[ arg(
@@ -107,6 +99,19 @@ pub struct RunArgs {
10799 pub command : Vec < String > ,
108100}
109101
102+ #[ derive( ValueEnum , Clone , Default , Debug , Serialize ) ]
103+ #[ serde( rename_all = "lowercase" ) ]
104+ pub enum RunnerMode {
105+ #[ default]
106+ Instrumentation ,
107+ Walltime ,
108+ }
109+
110+ #[ derive( ValueEnum , Clone , Debug , PartialEq ) ]
111+ pub enum MessageFormat {
112+ Json ,
113+ }
114+
110115#[ cfg( test) ]
111116impl RunArgs {
112117 /// Constructs a new `RunArgs` with default values for testing purposes
@@ -129,12 +134,7 @@ impl RunArgs {
129134}
130135
131136pub async fn run ( args : RunArgs , api_client : & CodSpeedAPIClient ) -> Result < ( ) > {
132- let output_json = args
133- . message_format
134- . as_ref ( )
135- . map ( |format| format == "json" )
136- . unwrap_or ( false ) ;
137-
137+ let output_json = args. message_format == Some ( MessageFormat :: Json ) ;
138138 let mut config = Config :: try_from ( args) ?;
139139 let provider = run_environment:: get_provider ( & config) ?;
140140 let codspeed_config = CodSpeedConfig :: load ( ) ?;
@@ -207,7 +207,8 @@ pub async fn run(args: RunArgs, api_client: &CodSpeedAPIClient) -> Result<()> {
207207 let run_id = upload_result. run_id . clone ( ) ;
208208 poll_results:: poll_results ( api_client, & provider, upload_result. run_id ) . await ?;
209209 if output_json {
210- // TODO: Refactor `log_json` to accept a serde_json::Value arguemnt
210+ // TODO: Refactor `log_json` to avoid having to format the json manually
211+ // We could make use of structured logging for this https://docs.rs/log/latest/log/#structured-logging
211212 log_json ! ( format!(
212213 "{{\" event\" : \" run_finished\" , \" run_id\" : \" {}\" }}" ,
213214 run_id
0 commit comments