Skip to content

Commit fb047aa

Browse files
committed
Use --start flag to start VM for 'clone' 'edit' and 'rename' commands
Signed-off-by: Praful Khanduri <holiodin@gmail.com>
1 parent d936fb0 commit fb047aa

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

cmd/limactl/clone.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff 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
}
@@ -48,6 +49,7 @@ func newRenameCommand() *cobra.Command {
4849
ValidArgsFunction: cloneBashComplete,
4950
GroupID: advancedCommand,
5051
}
52+
renameCommand.Flags().Bool("start", false, "Start the instance after renaming")
5153
editflags.RegisterEdit(renameCommand, "[limactl edit] ")
5254
return renameCommand
5355
}
@@ -113,15 +115,18 @@ func cloneOrRenameAction(cmd *cobra.Command, args []string) error {
113115
}
114116
}
115117

116-
if !tty {
117-
// use "start" to start it
118-
return nil
119-
}
120-
startNow, err := askWhetherToStart()
118+
start, err := flags.GetBool("start")
121119
if err != nil {
122120
return err
123121
}
124-
if !startNow {
122+
123+
if tty && !flags.Changed("start") {
124+
start, err = askWhetherToStart()
125+
if err != nil {
126+
return err
127+
}
128+
}
129+
if !start {
125130
return nil
126131
}
127132
err = reconcile.Reconcile(ctx, newInst.Name)

cmd/limactl/edit.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff 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,19 +141,23 @@ 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
}
158163
err = reconcile.Reconcile(ctx, inst.Name)

cmd/limactl/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ func newApp() *cobra.Command {
155155
}
156156

157157
if cmd.Flags().Changed("yes") {
158-
// Sets the value of the yesValue flag by using the yes flag.
158+
switch cmd.Name() {
159+
case "clone", "edit", "rename":
160+
logrus.Warn("--yes flag is deprecated (--tty=false is still supported and works in the same way. Also consider using --start)")
161+
}
162+
163+
// Sets the value of the yesValue flag by using the yes flag.
159164
yesValue, _ := cmd.Flags().GetBool("yes")
160165
if yesValue {
161166
// Sets to the default value false

0 commit comments

Comments
 (0)