@@ -5,7 +5,7 @@ use crate::self_update;
55use crate :: term2;
66use crate :: term2:: Terminal ;
77use clap:: { App , AppSettings , Arg , ArgGroup , ArgMatches , Shell , SubCommand } ;
8- use rustup:: dist:: dist:: { PartialTargetTriple , PartialToolchainDesc , TargetTriple } ;
8+ use rustup:: dist:: dist:: { PartialTargetTriple , PartialToolchainDesc , Profile , TargetTriple } ;
99use rustup:: dist:: manifest:: Component ;
1010use rustup:: utils:: utils:: { self , ExitCode } ;
1111use rustup:: { command, Cfg , Toolchain } ;
@@ -44,6 +44,7 @@ pub fn main() -> Result<()> {
4444 ( "show" , Some ( c) ) => match c. subcommand ( ) {
4545 ( "active-toolchain" , Some ( _) ) => handle_epipe ( show_active_toolchain ( cfg) ) ?,
4646 ( "home" , Some ( _) ) => handle_epipe ( show_rustup_home ( cfg) ) ?,
47+ ( "profile" , Some ( _) ) => handle_epipe ( show_profile ( cfg) ) ?,
4748 ( _, _) => handle_epipe ( show ( cfg) ) ?,
4849 } ,
4950 ( "install" , Some ( m) ) => update ( cfg, m) ?,
@@ -86,6 +87,7 @@ pub fn main() -> Result<()> {
8687 } ,
8788 ( "set" , Some ( c) ) => match c. subcommand ( ) {
8889 ( "default-host" , Some ( m) ) => set_default_host_triple ( & cfg, m) ?,
90+ ( "profile" , Some ( m) ) => set_profile ( & cfg, m) ?,
8991 ( _, _) => unreachable ! ( ) ,
9092 } ,
9193 ( "completions" , Some ( c) ) => {
@@ -125,7 +127,7 @@ pub fn cli() -> App<'static, 'static> {
125127 )
126128 . subcommand (
127129 SubCommand :: with_name ( "show" )
128- . about ( "Show the active and installed toolchains" )
130+ . about ( "Show the active and installed toolchains or profiles " )
129131 . after_help ( SHOW_HELP )
130132 . setting ( AppSettings :: VersionlessSubcommands )
131133 . setting ( AppSettings :: DeriveDisplayOrder )
@@ -138,6 +140,7 @@ pub fn cli() -> App<'static, 'static> {
138140 SubCommand :: with_name ( "home" )
139141 . about ( "Display the computed value of RUSTUP_HOME" ) ,
140142 )
143+ . subcommand ( SubCommand :: with_name ( "profile" ) . about ( "Show the current profile" ) ) ,
141144 )
142145 . subcommand (
143146 SubCommand :: with_name ( "install" )
@@ -501,6 +504,16 @@ pub fn cli() -> App<'static, 'static> {
501504 SubCommand :: with_name ( "default-host" )
502505 . about ( "The triple used to identify toolchains when not specified" )
503506 . arg ( Arg :: with_name ( "host_triple" ) . required ( true ) ) ,
507+ )
508+ . subcommand (
509+ SubCommand :: with_name ( "profile" )
510+ . about ( "The default components installed" )
511+ . arg (
512+ Arg :: with_name ( "profile-name" )
513+ . required ( true )
514+ . possible_values ( Profile :: names ( ) )
515+ . default_value ( Profile :: default_name ( ) ) ,
516+ ) ,
504517 ) ,
505518 ) ;
506519
@@ -919,7 +932,11 @@ fn target_add(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
919932 }
920933
921934 for target in & targets {
922- let new_component = Component :: new ( "rust-std" . to_string ( ) , Some ( TargetTriple :: new ( target) ) ) ;
935+ let new_component = Component :: new (
936+ "rust-std" . to_string ( ) ,
937+ Some ( TargetTriple :: new ( target) ) ,
938+ false ,
939+ ) ;
923940 toolchain. add_component ( new_component) ?;
924941 }
925942
@@ -930,7 +947,11 @@ fn target_remove(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
930947 let toolchain = explicit_or_dir_toolchain ( cfg, m) ?;
931948
932949 for target in m. values_of ( "target" ) . expect ( "" ) {
933- let new_component = Component :: new ( "rust-std" . to_string ( ) , Some ( TargetTriple :: new ( target) ) ) ;
950+ let new_component = Component :: new (
951+ "rust-std" . to_string ( ) ,
952+ Some ( TargetTriple :: new ( target) ) ,
953+ false ,
954+ ) ;
934955
935956 toolchain. remove_component ( new_component) ?;
936957 }
@@ -959,7 +980,7 @@ fn component_add(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
959980 } ) ;
960981
961982 for component in m. values_of ( "component" ) . expect ( "" ) {
962- let new_component = Component :: new ( component. to_string ( ) , target. clone ( ) ) ;
983+ let new_component = Component :: new ( component. to_string ( ) , target. clone ( ) , true ) ;
963984
964985 toolchain. add_component ( new_component) ?;
965986 }
@@ -978,7 +999,7 @@ fn component_remove(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
978999 } ) ;
9791000
9801001 for component in m. values_of ( "component" ) . expect ( "" ) {
981- let new_component = Component :: new ( component. to_string ( ) , target. clone ( ) ) ;
1002+ let new_component = Component :: new ( component. to_string ( ) , target. clone ( ) , true ) ;
9821003
9831004 toolchain. remove_component ( new_component) ?;
9841005 }
@@ -1159,6 +1180,19 @@ fn set_default_host_triple(cfg: &Cfg, m: &ArgMatches<'_>) -> Result<()> {
11591180 Ok ( ( ) )
11601181}
11611182
1183+ fn set_profile ( cfg : & Cfg , m : & ArgMatches ) -> Result < ( ) > {
1184+ cfg. set_profile ( & m. value_of ( "profile-name" ) . unwrap ( ) ) ?;
1185+ Ok ( ( ) )
1186+ }
1187+
1188+ fn show_profile ( cfg : & Cfg ) -> Result < ( ) > {
1189+ match cfg. get_profile ( ) ? {
1190+ Some ( p) => println ! ( "{}" , p) ,
1191+ None => println ! ( "No profile set" ) ,
1192+ }
1193+ Ok ( ( ) )
1194+ }
1195+
11621196#[ derive( Copy , Clone , Debug , PartialEq ) ]
11631197pub enum CompletionCommand {
11641198 Rustup ,
0 commit comments