File tree Expand file tree Collapse file tree 3 files changed +28
-12
lines changed Expand file tree Collapse file tree 3 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ Not to be confused with 'limactl copy' ('limactl cp').
3434 ValidArgsFunction : cloneBashComplete ,
3535 GroupID : advancedCommand ,
3636 }
37+ cloneCommand .Flags ().Bool ("start" , false , "Start the instance after cloning" )
3738 editflags .RegisterEdit (cloneCommand , "[limactl edit] " )
3839 return cloneCommand
3940}
@@ -98,17 +99,21 @@ func cloneAction(cmd *cobra.Command, args []string) error {
9899 }
99100 }
100101
101- if ! tty {
102- // use "start" to start it
103- return nil
104- }
105- startNow , err := askWhetherToStart ()
102+ start , err := flags .GetBool ("start" )
106103 if err != nil {
107104 return err
108105 }
109- if ! startNow {
106+
107+ if tty && ! flags .Changed ("start" ) {
108+ start , err = askWhetherToStart ()
109+ if err != nil {
110+ return err
111+ }
112+ }
113+ if ! start {
110114 return nil
111115 }
116+
112117 err = networks .Reconcile (ctx , newInst .Name )
113118 if err != nil {
114119 return err
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ func newEditCommand() *cobra.Command {
3636 ValidArgsFunction : editBashComplete ,
3737 GroupID : basicCommand ,
3838 }
39+ editCommand .Flags ().Bool ("start" , false , "Start the instance after editing" )
3940 editflags .RegisterEdit (editCommand , "" )
4041 return editCommand
4142}
@@ -140,21 +141,26 @@ func editAction(cmd *cobra.Command, args []string) error {
140141 logrus .Infof ("Instance %q configuration edited" , inst .Name )
141142 }
142143
143- if ! tty {
144- // use "start" to start it
145- return nil
146- }
147144 if inst == nil {
148145 // edited a limayaml file directly
149146 return nil
150147 }
151- startNow , err := askWhetherToStart ()
148+
149+ start , err := flags .GetBool ("start" )
152150 if err != nil {
153151 return err
154152 }
155- if ! startNow {
153+
154+ if tty && ! flags .Changed ("start" ) {
155+ start , err = askWhetherToStart ()
156+ if err != nil {
157+ return err
158+ }
159+ }
160+ if ! start {
156161 return nil
157162 }
163+
158164 err = networks .Reconcile (ctx , inst .Name )
159165 if err != nil {
160166 return err
Original file line number Diff line number Diff line change @@ -143,6 +143,11 @@ func newApp() *cobra.Command {
143143 }
144144
145145 if cmd .Flags ().Changed ("yes" ) {
146+ switch cmd .Name () {
147+ case "clone" , "edit" :
148+ logrus .Warn ("--yes flag is deprecated (--tty=false is still supported and works in the same way. Also consider using --start)" )
149+ }
150+
146151 // Sets the value of the yesValue flag by using the yes flag.
147152 yesValue , _ := cmd .Flags ().GetBool ("yes" )
148153 if yesValue {
You can’t perform that action at this time.
0 commit comments