@@ -32,6 +32,7 @@ use tracing_subscriber::{EnvFilter, Registry, reload::Handle};
3232
3333use crate :: {
3434 cli:: {
35+ ci,
3536 common:: { self , PackageUpdate , update_console_filter} ,
3637 docs,
3738 errors:: CliError ,
@@ -300,6 +301,13 @@ enum RustupSubcmd {
300301 #[ arg( default_value = "rustup" ) ]
301302 command : CompletionCommand ,
302303 } ,
304+
305+ /// Generate CI-specific configurations
306+ #[ command( hide = true ) ]
307+ Ci {
308+ #[ command( subcommand) ]
309+ subcmd : CiSubcmd ,
310+ } ,
303311}
304312
305313fn update_toolchain_value_parser ( s : & str ) -> Result < PartialToolchainDesc > {
@@ -322,6 +330,7 @@ impl RustupSubcmd {
322330 // These subcommands don't require the active toolchain, so auto-installing it should be
323331 // disabled to avoid surprises.
324332 Self :: Check { .. }
333+ | Self :: Ci { .. }
325334 | Self :: Completions { .. }
326335 | Self :: Component { .. }
327336 | Self :: Default { .. }
@@ -343,7 +352,10 @@ impl RustupSubcmd {
343352 fn should_warn_empty_setup ( & self ) -> bool {
344353 match self {
345354 // These subcommands are not about toolchains, so the hint would be noise.
346- Self :: Completions { .. } | Self :: DumpTestament | Self :: Self_ { .. } => false ,
355+ Self :: Ci { .. }
356+ | Self :: Completions { .. }
357+ | Self :: DumpTestament
358+ | Self :: Self_ { .. } => false ,
347359
348360 // For all other subcommands, the hint may be useful if rustup is still unusable after
349361 // the command has completed.
@@ -670,6 +682,20 @@ enum SetSubcmd {
670682 } ,
671683}
672684
685+ #[ derive( Debug , Subcommand ) ]
686+ #[ command( arg_required_else_help = true , subcommand_required = true ) ]
687+ enum CiSubcmd {
688+ /// Show the recommended environment variables in `.env` format
689+ Env ,
690+
691+ /// Show the example problem matcher for the given CI flavor
692+ #[ command( alias = "matcher" ) ]
693+ ProblemMatcher {
694+ #[ arg( value_enum) ]
695+ flavor : ci:: Flavor ,
696+ } ,
697+ }
698+
673699#[ tracing:: instrument( level = "trace" , fields( args = format!( "{:?}" , process. args_os( ) . collect:: <Vec <_>>( ) ) ) , skip( process, console_filter) ) ]
674700pub async fn main (
675701 current_dir : PathBuf ,
@@ -863,6 +889,10 @@ pub async fn main(
863889 RustupSubcmd :: Completions { shell, command } => {
864890 output_completion_script ( shell, command, process)
865891 }
892+ RustupSubcmd :: Ci { subcmd } => match subcmd {
893+ CiSubcmd :: Env => ci:: env ( cfg) ,
894+ CiSubcmd :: ProblemMatcher { flavor } => ci:: problem_matcher ( flavor, cfg) ,
895+ } ,
866896 } ?;
867897
868898 if should_warn && cfg. list_toolchains ( ) ?. is_empty ( ) && cfg. get_default ( ) ?. is_none ( ) {
0 commit comments