File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff 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
6970func 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 }
You can’t perform that action at this time.
0 commit comments