Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cmd/limactl/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ func newShellCommand() *cobra.Command {
shellCmd.Flags().String("workdir", "", "Working directory")
shellCmd.Flags().Bool("reconnect", false, "Reconnect to the SSH session")
shellCmd.Flags().Bool("preserve-env", false, "Propagate environment variables to the shell")
shellCmd.Flags().Bool("start", false, "Start the instance if it is not already running")
return shellCmd
}

func shellAction(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
flags := cmd.Flags()
// simulate the behavior of double dash
newArg := []string{}
if len(args) >= 2 && args[1] == "--" {
Expand All @@ -93,11 +95,18 @@ func shellAction(cmd *cobra.Command, args []string) error {
return err
}
if inst.Status == limatype.StatusStopped {
startNow, err := askWhetherToStart()
startNow, err := flags.GetBool("start")
if err != nil {
return err
}

if !flags.Changed("start") {
startNow, err = askWhetherToStart()
if err != nil {
return err
}
}

if !startNow {
return nil
}
Expand Down
Loading