File tree 2 files changed +24
-4
lines changed
2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ pub fn build_cli() -> Command {
104
104
. subcommand (
105
105
Command :: new ( "config" )
106
106
. arg ( instance_arg. clone ( ) . help ( "Instance to be configured" ) )
107
- . arg ( Arg :: new ( "g" ) . short ( 'g' ) . action ( clap:: ArgAction :: SetTrue ) . conflicts_with ( "INSTANCE" ) . help ( "Configure base system instead of an instance" ) )
107
+ . arg ( Arg :: new ( "g" ) . short ( 'g' ) . action ( clap:: ArgAction :: SetTrue ) . help ( "Configure base system instead of an instance" ) )
108
108
. about ( "Configure system and toolchain for building interactively" ) ,
109
109
)
110
110
. subcommand (
Original file line number Diff line number Diff line change @@ -233,12 +233,32 @@ fn main() -> Result<()> {
233
233
print_error ! ( { actions:: update_os( force_use_apt, ) } ) ;
234
234
}
235
235
( "config" , args) => {
236
- if args. get_flag ( "g" ) {
236
+ // HACK: To improve UX, we allow -i and -g to be implicitly specified through environment variable
237
+ // and then we check if user explicitly specified -i
238
+ let has_global_flag = args. get_flag ( "g" ) ;
239
+ let instance = get_instance_option ( args) . ok ( ) ;
240
+ let instance_from_env = if let Some ( ref inst) = instance {
241
+ std:: env:: var ( "CIEL_INST" )
242
+ . map ( |x| & x == inst)
243
+ . unwrap_or ( false )
244
+ } else {
245
+ true
246
+ } ;
247
+ if !instance_from_env && has_global_flag {
248
+ error ! ( "Cannot use -g and -i together." ) ;
249
+ process:: exit ( 1 ) ;
250
+ }
251
+ if has_global_flag {
237
252
print_error ! ( { actions:: config_os( None ) } ) ;
238
253
return Ok ( ( ) ) ;
239
254
}
240
- let instance = get_instance_option ( args) ?;
241
- print_error ! ( { actions:: config_os( Some ( & instance) ) } ) ;
255
+ if let Some ( inst) = instance {
256
+ info ! ( "Configuring for {}" , inst) ;
257
+ print_error ! ( { actions:: config_os( Some ( & inst) ) } ) ;
258
+ return Ok ( ( ) ) ;
259
+ }
260
+
261
+ return Err ( anyhow ! ( "No instance specified!" ) ) ;
242
262
}
243
263
( "mount" , args) => {
244
264
print_error ! ( { one_or_all_instance!( args, & actions:: mount_fs) } ) ;
You can’t perform that action at this time.
0 commit comments