@@ -71,7 +71,7 @@ func runNetworkCreate(c *cli.Context) error {
7171 output .Render (c , n , func () {
7272 pterm .Success .Printfln ("Created network %s (%s)" , n .Name , n .ID )
7373 pterm .Println (pterm .Gray (" Attach at create time: createos sandbox create --network " + n .Name ))
74- pterm .Println (pterm .Gray (" Or live-attach later: createos sandbox network attach <sandbox> " + n .Name ))
74+ pterm .Println (pterm .Gray (" Or live-attach later: createos sandbox network attach " + n .Name + " <sandbox>" ))
7575 })
7676 return nil
7777}
@@ -315,7 +315,7 @@ func newNetworkAttachCommand() *cli.Command {
315315 return & cli.Command {
316316 Name : "attach" ,
317317 Usage : "Add a sandbox or device to a network" ,
318- ArgsUsage : "[<sandbox|device > <network >]" ,
318+ ArgsUsage : "[<network > <sandbox|device >]" ,
319319 Action : runNetworkAttach ,
320320 }
321321}
@@ -334,41 +334,41 @@ func runNetworkAttach(c *cli.Context) error {
334334 return fmt .Errorf ("you're not signed in — run 'createos login' to get started" )
335335 }
336336 args := c .Args ().Slice ()
337- ref , netRef := "" , ""
337+ netRef , ref := "" , ""
338338 if len (args ) > 0 {
339- ref = args [0 ]
339+ netRef = args [0 ]
340340 }
341341 if len (args ) > 1 {
342- netRef = args [1 ]
342+ ref = args [1 ]
343343 }
344344 tty := terminal .IsInteractive ()
345- if ref == "" {
345+ if netRef == "" {
346346 if ! tty {
347- return fmt .Errorf ("usage: createos sandbox network attach <sandbox|device > <network >" )
347+ return fmt .Errorf ("usage: createos sandbox network attach <network > <sandbox|device >" )
348348 }
349- picked , err := pickEndpoint (c , client , "Attach what ?" )
349+ picked , err := pickNetwork (c , client , "Attach to which network ?" )
350350 if err != nil {
351351 return err
352352 }
353353 if picked == "" {
354354 fmt .Println ("Cancelled." )
355355 return nil
356356 }
357- ref = picked
357+ netRef = picked
358358 }
359- if netRef == "" {
359+ if ref == "" {
360360 if ! tty {
361- return fmt .Errorf ("usage: createos sandbox network attach <sandbox|device > <network >" )
361+ return fmt .Errorf ("usage: createos sandbox network attach <network > <sandbox|device >" )
362362 }
363- picked , err := pickNetwork (c , client , "Attach to which network ?" )
363+ picked , err := pickEndpoint (c , client , "Attach what ?" )
364364 if err != nil {
365365 return err
366366 }
367367 if picked == "" {
368368 fmt .Println ("Cancelled." )
369369 return nil
370370 }
371- netRef = picked
371+ ref = picked
372372 }
373373 if isDeviceRef (ref ) {
374374 if err := client .AttachDeviceToNetwork (c .Context , ref , netRef ); err != nil {
@@ -396,7 +396,7 @@ func newNetworkDetachCommand() *cli.Command {
396396 return & cli.Command {
397397 Name : "detach" ,
398398 Usage : "Remove a sandbox or device from a network" ,
399- ArgsUsage : "[<sandbox|device > <network >]" ,
399+ ArgsUsage : "[<network > <sandbox|device >]" ,
400400 Flags : []cli.Flag {
401401 & cli.BoolFlag {Name : "yes" , Aliases : []string {"y" }, Usage : "Skip the confirmation prompt" },
402402 },
@@ -410,41 +410,41 @@ func runNetworkDetach(c *cli.Context) error {
410410 return fmt .Errorf ("you're not signed in — run 'createos login' to get started" )
411411 }
412412 args := c .Args ().Slice ()
413- ref , netRef := "" , ""
413+ netRef , ref := "" , ""
414414 if len (args ) > 0 {
415- ref = args [0 ]
415+ netRef = args [0 ]
416416 }
417417 if len (args ) > 1 {
418- netRef = args [1 ]
418+ ref = args [1 ]
419419 }
420420 tty := terminal .IsInteractive ()
421- if ref == "" {
421+ if netRef == "" {
422422 if ! tty {
423- return fmt .Errorf ("usage: createos sandbox network detach <sandbox|device > <network >" )
423+ return fmt .Errorf ("usage: createos sandbox network detach <network > <sandbox|device >" )
424424 }
425- picked , err := pickEndpoint (c , client , "Detach what ?" )
425+ picked , err := pickNetwork (c , client , "Detach from which network ?" )
426426 if err != nil {
427427 return err
428428 }
429429 if picked == "" {
430430 fmt .Println ("Cancelled." )
431431 return nil
432432 }
433- ref = picked
433+ netRef = picked
434434 }
435- if netRef == "" {
435+ if ref == "" {
436436 if ! tty {
437- return fmt .Errorf ("usage: createos sandbox network detach <sandbox|device > <network >" )
437+ return fmt .Errorf ("usage: createos sandbox network detach <network > <sandbox|device >" )
438438 }
439- picked , err := pickNetwork (c , client , "Detach from which network ?" )
439+ picked , err := pickEndpoint (c , client , "Detach what ?" )
440440 if err != nil {
441441 return err
442442 }
443443 if picked == "" {
444444 fmt .Println ("Cancelled." )
445445 return nil
446446 }
447- netRef = picked
447+ ref = picked
448448 }
449449 force := c .Bool ("yes" )
450450 if ! tty && ! force {
0 commit comments