@@ -166,24 +166,37 @@ impl UpCommand {
166
166
& self . bindle_source ,
167
167
& self . registry_source ,
168
168
) {
169
- ( None , None , None , None ) => Self :: default_manifest_or_none ( ) ,
169
+ ( None , None , None , None ) => self . default_manifest_or_none ( ) ,
170
170
( Some ( source) , None , None , None ) => Self :: infer_source ( source) ,
171
171
( None , Some ( file) , None , None ) => Self :: infer_file_source ( file. to_owned ( ) ) ,
172
172
( None , None , Some ( id) , None ) => AppSource :: Bindle ( id. to_owned ( ) ) ,
173
173
( None , None , None , Some ( reference) ) => AppSource :: OciRegistry ( reference. to_owned ( ) ) ,
174
- ( _ , _ , _ , _ ) => AppSource :: unresolvable ( "More than one application was specified" ) ,
174
+ _ => AppSource :: unresolvable ( "More than one application was specified" ) ,
175
175
}
176
176
}
177
177
178
- fn default_manifest_or_none ( ) -> AppSource {
178
+ fn default_manifest_or_none ( & self ) -> AppSource {
179
179
let default_manifest = PathBuf :: from ( DEFAULT_MANIFEST_FILE ) ;
180
180
if default_manifest. exists ( ) {
181
181
AppSource :: File ( default_manifest)
182
+ } else if self . trigger_args_look_file_like ( ) {
183
+ let msg = format ! (
184
+ "Default file 'spin.toml' found. Did you mean `spin up -f {}`?`" ,
185
+ self . trigger_args[ 0 ] . to_string_lossy( )
186
+ ) ;
187
+ AppSource :: Unresolvable ( msg)
182
188
} else {
183
189
AppSource :: None
184
190
}
185
191
}
186
192
193
+ fn trigger_args_look_file_like ( & self ) -> bool {
194
+ // Heuristic for the user typing `spin up foo` instead of `spin up -f foo` - in the
195
+ // first case `foo` gets interpreted as a trigger arg which is probably not what the
196
+ // user intended.
197
+ !self . trigger_args . is_empty ( ) && !self . trigger_args [ 0 ] . to_string_lossy ( ) . starts_with ( '-' )
198
+ }
199
+
187
200
fn infer_file_source ( path : PathBuf ) -> AppSource {
188
201
if path. is_file ( ) {
189
202
AppSource :: File ( path)
@@ -361,6 +374,7 @@ impl UpCommand {
361
374
& self ,
362
375
mut locked_app : LockedApp ,
363
376
working_dir : PathBuf ,
377
+ needs_registry_flag : bool ,
364
378
) -> Result < ( Vec < String > , TriggerExecOpts ) > {
365
379
// Apply --env to component environments
366
380
if !self . env . is_empty ( ) {
@@ -375,11 +389,10 @@ impl UpCommand {
375
389
let exec_opts = if self . help {
376
390
TriggerExecOpts :: NoApp
377
391
} else {
378
- let from_registry = self . registry_source . is_some ( ) ;
379
392
TriggerExecOpts :: Remote {
380
393
locked_url,
381
394
working_dir,
382
- from_registry,
395
+ from_registry : needs_registry_flag ,
383
396
}
384
397
} ;
385
398
@@ -440,7 +453,7 @@ impl UpCommand {
440
453
. context ( "cannot get path to spin.lock" ) ?;
441
454
442
455
let locked_app: LockedApp = serde_json:: from_slice ( & tokio:: fs:: read ( & app_path) . await ?) ?;
443
- self . prepare_locked_app ( locked_app, working_dir) . await
456
+ self . prepare_locked_app ( locked_app, working_dir, true ) . await
444
457
}
445
458
446
459
async fn prepare_app_from_bindle (
@@ -457,7 +470,8 @@ impl UpCommand {
457
470
} ;
458
471
459
472
let locked_app = spin_trigger:: locked:: build_locked_app ( app, & working_dir) ?;
460
- self . prepare_locked_app ( locked_app, working_dir) . await
473
+ self . prepare_locked_app ( locked_app, working_dir, false )
474
+ . await
461
475
}
462
476
}
463
477
@@ -579,19 +593,6 @@ impl AppSource {
579
593
}
580
594
}
581
595
582
- #[ derive( Clone , Debug , clap:: ValueEnum ) ]
583
- enum AppSourceType {
584
- Auto ,
585
- File ,
586
- Oci ,
587
- }
588
-
589
- impl Default for AppSourceType {
590
- fn default ( ) -> Self {
591
- Self :: Auto
592
- }
593
- }
594
-
595
596
#[ cfg( test) ]
596
597
mod test {
597
598
use super :: * ;
0 commit comments