@@ -1182,7 +1182,7 @@ enum SandboxCommands {
11821182 /// `.gitignore` rules are applied by default; use `--no-git-ignore` to
11831183 /// upload everything.
11841184 #[ arg( long, value_hint = ValueHint :: AnyPath , help_heading = "UPLOAD FLAGS" ) ]
1185- upload : Option < String > ,
1185+ upload : Vec < String > ,
11861186
11871187 /// Disable `.gitignore` filtering for `--upload`.
11881188 #[ arg( long, requires = "upload" , help_heading = "UPLOAD FLAGS" ) ]
@@ -2577,11 +2577,22 @@ async fn main() -> Result<()> {
25772577 labels_map. insert ( parts[ 0 ] . to_string ( ) , parts[ 1 ] . to_string ( ) ) ;
25782578 }
25792579
2580- // Parse --upload spec into (local_path, sandbox_path, git_ignore).
2581- let upload_spec = upload. as_deref ( ) . map ( |s| {
2582- let ( local, remote) = parse_upload_spec ( s) ;
2583- ( local, remote, !no_git_ignore)
2584- } ) ;
2580+ // Parse --upload specs into [(local_path, sandbox_path, git_ignore)].
2581+ let upload_specs: Vec < ( String , Option < String > , bool ) > = upload
2582+ . iter ( )
2583+ . map ( |s| {
2584+ let ( local, remote) = parse_upload_spec ( s) ;
2585+ ( local, remote, !no_git_ignore)
2586+ } )
2587+ . collect ( ) ;
2588+
2589+ // Validate all local paths before creating the sandbox so failures are
2590+ // fast and have no side effects.
2591+ for ( local, _, _) in & upload_specs {
2592+ if !run:: local_upload_path_exists ( std:: path:: Path :: new ( local) ) {
2593+ return Err ( miette:: miette!( "local path does not exist: {}" , local) ) ;
2594+ }
2595+ }
25852596
25862597 let editor = editor. map ( Into :: into) ;
25872598 let forward = forward
@@ -2598,7 +2609,7 @@ async fn main() -> Result<()> {
25982609 name. as_deref ( ) ,
25992610 from. as_deref ( ) ,
26002611 & ctx. name ,
2601- upload_spec . as_ref ( ) ,
2612+ & upload_specs ,
26022613 keep,
26032614 gpu,
26042615 gpu_device. as_deref ( ) ,
@@ -3479,6 +3490,43 @@ mod tests {
34793490 assert_eq ! ( remote, None ) ;
34803491 }
34813492
3493+ #[ test]
3494+ fn sandbox_create_upload_flag_accepts_multiple_values ( ) {
3495+ let result = Cli :: try_parse_from ( [
3496+ "openshell" ,
3497+ "sandbox" ,
3498+ "create" ,
3499+ "--upload" ,
3500+ "./src:/workspace/src" ,
3501+ "--upload" ,
3502+ "./config:/workspace/config" ,
3503+ ] ) ;
3504+ assert ! (
3505+ result. is_ok( ) ,
3506+ "--upload should be repeatable, got: {:?}" ,
3507+ result. err( )
3508+ ) ;
3509+ }
3510+
3511+ #[ test]
3512+ fn sandbox_create_upload_flag_accepts_zero_values ( ) {
3513+ let result = Cli :: try_parse_from ( [ "openshell" , "sandbox" , "create" ] ) ;
3514+ assert ! (
3515+ result. is_ok( ) ,
3516+ "sandbox create with no --upload should succeed, got: {:?}" ,
3517+ result. err( )
3518+ ) ;
3519+ }
3520+
3521+ #[ test]
3522+ fn sandbox_create_no_git_ignore_requires_upload ( ) {
3523+ let result = Cli :: try_parse_from ( [ "openshell" , "sandbox" , "create" , "--no-git-ignore" ] ) ;
3524+ assert ! (
3525+ result. is_err( ) ,
3526+ "--no-git-ignore without --upload should be rejected"
3527+ ) ;
3528+ }
3529+
34823530 #[ test]
34833531 fn resolve_sandbox_name_returns_explicit_name ( ) {
34843532 // When a name is provided, it should be returned regardless of any
0 commit comments