@@ -10,6 +10,7 @@ import (
1010 "path/filepath"
1111 "strings"
1212
13+ "github.com/stuartleeks/devcontainer-cli/internal/pkg/terminal"
1314 "github.com/stuartleeks/devcontainer-cli/internal/pkg/wsl"
1415)
1516
@@ -126,6 +127,8 @@ func GetContainerIDForPath(devcontainerPath string) (string, error) {
126127
127128func ExecInDevContainer (containerIDOrName string , workDir string , args []string ) error {
128129
130+ statusWriter := & terminal.UpdatingStatusWriter {}
131+
129132 containerID := ""
130133 devcontainerList , err := ListDevcontainers ()
131134 if err != nil {
@@ -151,6 +154,7 @@ func ExecInDevContainer(containerIDOrName string, workDir string, args []string)
151154 return err
152155 }
153156
157+ statusWriter .Printf ("Getting mount path" )
154158 if workDir == "" {
155159 workDir , err = GetWorkspaceMountPath (localPath )
156160 if err != nil {
@@ -160,18 +164,21 @@ func ExecInDevContainer(containerIDOrName string, workDir string, args []string)
160164
161165 wslPath := localPath
162166 if strings .HasPrefix (wslPath , "\\ \\ wsl$" ) && wsl .IsWsl () {
167+ statusWriter .Printf ("Converting to WSL path" )
163168 wslPath , err = wsl .ConvertWindowsPathToWslPath (wslPath )
164169 if err != nil {
165170 return fmt .Errorf ("error converting path: %s" , err )
166171 }
167172 }
168173
174+ statusWriter .Printf ("Getting user name" )
169175 devcontainerJSONPath := path .Join (wslPath , ".devcontainer/devcontainer.json" )
170176 userName , err := GetDevContainerUserName (devcontainerJSONPath )
171177 if err != nil {
172178 return err
173179 }
174180
181+ statusWriter .Printf ("Checking for SSH_AUTH_SOCK" )
175182 sshAuthSockValue , err := getSshAuthSockValue (containerID )
176183 if err != nil {
177184 // output error and continue without SSH_AUTH_SOCK value
@@ -180,9 +187,11 @@ func ExecInDevContainer(containerIDOrName string, workDir string, args []string)
180187 fmt .Println ("Continuing without setting SSH_AUTH_SOCK..." )
181188 }
182189
190+ statusWriter .Printf ("Getting container PATH" )
183191 containerPath , err := getContainerEnvVar (containerID , "PATH" )
184192 if err == nil {
185193 // Got the PATH
194+ statusWriter .Printf ("Getting code server path" )
186195 vscodeServerPath , err := getVscodeServerPath (containerID )
187196 if err == nil {
188197 // Got the VS Code server location - add bin subfolder to PATH
@@ -200,13 +209,15 @@ func ExecInDevContainer(containerIDOrName string, workDir string, args []string)
200209 fmt .Println ("Continuing without overriding PATH..." )
201210 }
202211
212+ statusWriter .Printf ("Getting code IPC SOCK" )
203213 ipcSock , err := getVscodeIpcSock (containerID )
204214 if err != nil {
205215 ipcSock = ""
206216 fmt .Printf ("Warning; Failed to get VS Code IPC SOCK: %s\n " , err )
207217 fmt .Println ("Continuing without setting VSCODE_IPC_HOOK_CLI..." )
208218 }
209219
220+ statusWriter .Printf ("Starting exec session\n " ) // newline to put container shell at start of line
210221 dockerArgs := []string {"exec" , "-it" , "--workdir" , workDir }
211222 if userName != "" {
212223 dockerArgs = append (dockerArgs , "--user" , userName )
0 commit comments