@@ -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
@@ -88,8 +80,8 @@ pub struct RunArgs {
8880 #[ arg( long) ]
8981 pub mongo_uri_env_name : Option < String > ,
9082
91- #[ arg( long) ]
92- pub message_format : Option < String > ,
83+ #[ arg( long, hide = true ) ]
84+ pub message_format : Option < MessageFormat > ,
9385
9486 /// Only for debugging purposes, skips the upload of the results
9587 #[ arg(
@@ -108,6 +100,19 @@ pub struct RunArgs {
108100 pub command : Vec < String > ,
109101}
110102
103+ #[ derive( ValueEnum , Clone , Default , Debug , Serialize ) ]
104+ #[ serde( rename_all = "lowercase" ) ]
105+ pub enum RunnerMode {
106+ #[ default]
107+ Instrumentation ,
108+ Walltime ,
109+ }
110+
111+ #[ derive( ValueEnum , Clone , Debug , PartialEq ) ]
112+ pub enum MessageFormat {
113+ Json ,
114+ }
115+
111116#[ cfg( test) ]
112117impl RunArgs {
113118 /// Constructs a new `RunArgs` with default values for testing purposes
@@ -130,12 +135,7 @@ impl RunArgs {
130135}
131136
132137pub async fn run ( args : RunArgs , api_client : & CodSpeedAPIClient ) -> Result < ( ) > {
133- let output_json = args
134- . message_format
135- . as_ref ( )
136- . map ( |format| format == "json" )
137- . unwrap_or ( false ) ;
138-
138+ let output_json = args. message_format == Some ( MessageFormat :: Json ) ;
139139 let mut config = Config :: try_from ( args) ?;
140140 let provider = run_environment:: get_provider ( & config) ?;
141141 let codspeed_config = CodSpeedConfig :: load ( ) ?;
@@ -208,7 +208,8 @@ pub async fn run(args: RunArgs, api_client: &CodSpeedAPIClient) -> Result<()> {
208208 let run_id = upload_result. run_id . clone ( ) ;
209209 poll_results:: poll_results ( api_client, & provider, upload_result. run_id ) . await ?;
210210 if output_json {
211- // TODO: Refactor `log_json` to accept a serde_json::Value arguemnt
211+ // TODO: Refactor `log_json` to avoid having to format the json manually
212+ // We could make use of structured logging for this https://docs.rs/log/latest/log/#structured-logging
212213 log_json ! ( format!(
213214 "{{\" event\" : \" run_finished\" , \" run_id\" : \" {}\" }}" ,
214215 run_id
0 commit comments