Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions cmd/cmd_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ var (
flagSessionToken string
flagEnvFile string
flagCreateDebugSession bool
flagLocal bool

finalConfigFile string
finalConcurrency string
finalSessionToken string
finalConfigValueSource string
finalCreateDebugSession bool
finalLocal bool

finalGraphFile string
finalGraphArgs []string
Expand Down Expand Up @@ -109,6 +111,8 @@ var cmdRoot = &cobra.Command{
})
finalCreateDebugSession = finalCreateDebugSessionStr == "true" || finalCreateDebugSessionStr == "1"

finalLocal = flagLocal

// the block below is used to distinguish between implicit graph files (eg if defined in an env var) + graph flags
// vs explicit graph file (eg provided by positional arg) + graph flags.

Expand Down Expand Up @@ -147,6 +151,13 @@ var cmdRoot = &cobra.Command{
return errors.New("when using --create-debug-session, a graph file must be specified")
}

if finalLocal && finalSessionToken != "" {
return errors.New("--local and --session-token cannot be used together")
}
if finalLocal && finalCreateDebugSession {
return errors.New("--local and --create-debug-session cannot be used together")
}

return nil
},
}
Expand All @@ -155,6 +166,16 @@ func cmdRootRun(cmd *cobra.Command, args []string) {

utils.SetConcurrencyEnabled(finalConcurrency == "" || finalConcurrency == "true" || finalConcurrency == "1")

// start a local WS server for local connections (eg the vscode extension)
if finalLocal {
err := sessions.RunLocalMode(finalConfigFile)
if err != nil {
utils.LogErr.Print(err.Error())
os.Exit(1)
}
return
}

// if we still have no graph file, go to Session Mode
if finalGraphFile == "" || finalCreateDebugSession {
trapfn := func() {
Expand Down Expand Up @@ -231,6 +252,7 @@ func init() {
cmdRoot.Flags().StringVar(&flagConcurrency, "concurrency", "", "Enable or disable concurrency")
cmdRoot.Flags().StringVar(&flagSessionToken, "session-token", "", "The session token from your browser")
cmdRoot.Flags().BoolVar(&flagCreateDebugSession, "create-debug-session", false, "Create a debug session by connecting to the web app")
cmdRoot.Flags().BoolVar(&flagLocal, "local", false, "Start a local WebSocket server for direct editor connection")

// disable interspersed flag parsing to allow passing arbitrary flags to graphs.
// it stops cobra from parsing flags once it hits positional argument
Expand Down
2 changes: 1 addition & 1 deletion nodes/dir-walk@v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
})

} else {
entries, err := os.ReadDir(root)
entries, err := os.ReadDir(filepath.Clean(root))
if err != nil {
return "", core.CreateErr(nil, err, "failed to read directory")
}
Expand Down
2 changes: 2 additions & 0 deletions nodes/run@v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ func runCommand(c *core.ExecutionState, shell string, script *string, args []str
curEnvMap["PYTHONIOENCODING"] = "utf-8"

args = append([]string{scriptPath}, args...)
default:
return "", 0, core.CreateErr(c, nil, "unsupported shell: %s", shell)
}
cmd = exec.Command(shell, args...)

Expand Down
Loading
Loading