@@ -28,6 +28,7 @@ use tracing_subscriber::{EnvFilter, Registry, reload::Handle};
2828
2929use crate :: {
3030 cli:: {
31+ ci,
3132 common:: { self , PackageUpdate , update_console_filter} ,
3233 docs,
3334 errors:: CliError ,
@@ -296,6 +297,13 @@ enum RustupSubcmd {
296297 #[ arg( default_value = "rustup" ) ]
297298 command : CompletionCommand ,
298299 } ,
300+
301+ /// Generate CI-specific configurations
302+ #[ command( hide = true ) ]
303+ Ci {
304+ #[ command( subcommand) ]
305+ subcmd : CiSubcmd ,
306+ } ,
299307}
300308
301309fn update_toolchain_value_parser ( s : & str ) -> Result < PartialToolchainDesc > {
@@ -318,6 +326,7 @@ impl RustupSubcmd {
318326 // These subcommands don't require the active toolchain, so auto-installing it should be
319327 // disabled to avoid surprises.
320328 Self :: Check { .. }
329+ | Self :: Ci { .. }
321330 | Self :: Completions { .. }
322331 | Self :: Component { .. }
323332 | Self :: Default { .. }
@@ -344,6 +353,7 @@ impl RustupSubcmd {
344353 // For all other subcommands, the hint may be useful if rustup is still unusable after
345354 // the command has completed.
346355 Self :: Check { .. }
356+ | Self :: Ci { .. }
347357 | Self :: Component { .. }
348358 | Self :: Default { .. }
349359 | Self :: Doc { .. }
@@ -666,6 +676,20 @@ enum SetSubcmd {
666676 } ,
667677}
668678
679+ #[ derive( Debug , Subcommand ) ]
680+ #[ command( arg_required_else_help = true , subcommand_required = true ) ]
681+ enum CiSubcmd {
682+ /// Show the recommended environment variables in `.env` format
683+ Env ,
684+
685+ /// Show the example problem matcher for the given CI flavor
686+ #[ command( alias = "matcher" ) ]
687+ ProblemMatcher {
688+ #[ arg( value_enum) ]
689+ flavor : ci:: Flavor ,
690+ } ,
691+ }
692+
669693#[ tracing:: instrument( level = "trace" , fields( args = format!( "{:?}" , process. args_os( ) . collect:: <Vec <_>>( ) ) ) , skip( process, console_filter) ) ]
670694pub async fn main (
671695 current_dir : PathBuf ,
@@ -857,6 +881,10 @@ pub async fn main(
857881 RustupSubcmd :: Completions { shell, command } => {
858882 output_completion_script ( shell, command, process)
859883 }
884+ RustupSubcmd :: Ci { subcmd } => match subcmd {
885+ CiSubcmd :: Env => ci:: env ( cfg) ,
886+ CiSubcmd :: ProblemMatcher { flavor } => ci:: problem_matcher ( flavor, cfg) ,
887+ } ,
860888 } ?;
861889
862890 if should_warn && cfg. list_toolchains ( ) ?. is_empty ( ) && cfg. get_default ( ) ?. is_none ( ) {
0 commit comments