Skip to content

Commit 8a63421

Browse files
authored
Merge pull request #4285 from nlordell/feat/shell-start-flag
Add `--start` Flag to `limactl shell`
2 parents 808c80c + 8dac16a commit 8a63421

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cmd/limactl/shell.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ func newShellCommand() *cobra.Command {
6363
shellCmd.Flags().String("workdir", "", "Working directory")
6464
shellCmd.Flags().Bool("reconnect", false, "Reconnect to the SSH session")
6565
shellCmd.Flags().Bool("preserve-env", false, "Propagate environment variables to the shell")
66+
shellCmd.Flags().Bool("start", false, "Start the instance if it is not already running")
6667
return shellCmd
6768
}
6869

6970
func shellAction(cmd *cobra.Command, args []string) error {
7071
ctx := cmd.Context()
72+
flags := cmd.Flags()
7173
// simulate the behavior of double dash
7274
newArg := []string{}
7375
if len(args) >= 2 && args[1] == "--" {
@@ -93,11 +95,18 @@ func shellAction(cmd *cobra.Command, args []string) error {
9395
return err
9496
}
9597
if inst.Status == limatype.StatusStopped {
96-
startNow, err := askWhetherToStart()
98+
startNow, err := flags.GetBool("start")
9799
if err != nil {
98100
return err
99101
}
100102

103+
if !flags.Changed("start") {
104+
startNow, err = askWhetherToStart()
105+
if err != nil {
106+
return err
107+
}
108+
}
109+
101110
if !startNow {
102111
return nil
103112
}

0 commit comments

Comments
 (0)