Skip to content

Commit 1d9b696

Browse files
Robert WendtRobert Wendt
authored andcommitted
support opening vscode in directory other than proj dir with flag
1 parent 693cb98 commit 1d9b696

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/cmd/open/open.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type OpenStore interface {
4848

4949
func NewCmdOpen(t *terminal.Terminal, store OpenStore, noLoginStartStore OpenStore) *cobra.Command {
5050
var waitForSetupToFinish bool
51+
var directory string
5152

5253
cmd := &cobra.Command{
5354
Annotations: map[string]string{"ssh": ""},
@@ -63,20 +64,21 @@ func NewCmdOpen(t *terminal.Terminal, store OpenStore, noLoginStartStore OpenSto
6364
if waitForSetupToFinish {
6465
setupDoneString = "------ Done running execs ------"
6566
}
66-
err := runOpenCommand(t, store, args[0], setupDoneString)
67+
err := runOpenCommand(t, store, args[0], setupDoneString, directory)
6768
if err != nil {
6869
return breverrors.WrapAndTrace(err)
6970
}
7071
return nil
7172
},
7273
}
7374
cmd.Flags().BoolVarP(&waitForSetupToFinish, "wait", "w", false, "wait for setup to finish")
75+
cmd.Flags().StringVarP(&directory, "dir", "d", "", "directory to open")
7476

7577
return cmd
7678
}
7779

7880
// Fetch workspace info, then open code editor
79-
func runOpenCommand(t *terminal.Terminal, tstore OpenStore, wsIDOrName string, setupDoneString string) error {
81+
func runOpenCommand(t *terminal.Terminal, tstore OpenStore, wsIDOrName string, setupDoneString string, directory string) error {
8082
// todo check if workspace is stopped and start if it if it is stopped
8183
fmt.Println("finding your dev environment...")
8284
res := refresh.RunRefreshAsync(tstore)
@@ -108,6 +110,9 @@ func runOpenCommand(t *terminal.Terminal, tstore OpenStore, wsIDOrName string, s
108110
}
109111

110112
projPath := workspace.GetProjectFolderPath()
113+
if directory != "" {
114+
projPath = directory
115+
}
111116

112117
localIdentifier := workspace.GetLocalIdentifier()
113118

0 commit comments

Comments
 (0)