From 88391f663d8f35df4f8b878b150fa40ba235a40f Mon Sep 17 00:00:00 2001 From: Sebatian Rath Date: Tue, 3 Feb 2026 07:17:10 -0500 Subject: [PATCH] Update CLI flag naming to hyphens --- .vscode/launch.json | 4 +++- README.md | 10 ++++---- cmd/cmd_root.go | 23 ++++++++++++++----- sessions/session.go | 4 ++-- tests_e2e/references/reference_app.sh_l10 | 8 +++---- tests_e2e/references/reference_app.sh_l12 | 4 ++-- .../references/reference_contexts_env.sh_l26 | 8 +++---- .../references/reference_dir-walk.sh_l56 | 4 ++-- .../reference_error_no_output.sh_l8 | 4 ++-- .../reference_group-port-collision.sh_l13 | 4 ++-- tests_e2e/references/reference_index.sh_l20 | 4 ++-- .../reference_run-python-embedded.sh_l13 | 4 ++-- .../references/reference_s3_aws_walk.sh_l22 | 4 ++-- .../references/reference_s3_aws_walk.sh_l44 | 4 ++-- .../references/reference_select-data.sh_l9 | 4 ++-- .../reference_string-transform.sh_l61 | 4 ++-- 16 files changed, 55 insertions(+), 42 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 8700eb5..6168092 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,7 +13,9 @@ "CGO_ENABLED": "0" }, "args": [ - "--env_file=${workspaceFolder}/.env", + "/Users/sebastian/Desktop/test.act", + "--config_file=/Users/sebastian/Desktop/test.actconfig", + "--concurrency=1" ] }, { diff --git a/README.md b/README.md index 58faf14..afd7070 100644 --- a/README.md +++ b/README.md @@ -62,17 +62,17 @@ actrun ./my_graph.act --target="production" --verbose If you need to strictly separate CLI flags from graph arguments, use the `--` separator: ```bash -actrun --env_file=.env -- ./my_graph.act --target="production" +actrun --env-file=.env -- ./my_graph.act --target="production" ``` ### 🌍 3. Load Environment Variables -Inject environment variables from a file before execution starts using `--env_file`. +Inject environment variables from a file before execution starts using `--env-file`. ```bash -actrun --env_file=.env.local ./my_graph.act +actrun --env-file=.env.local ./my_graph.act ``` @@ -91,10 +91,10 @@ actrun validate ./complex_workflow.act ### πŸ•ΈοΈ Debug Sessions -`actrun` can bridge your local terminal to the Actionforge web app for visual debugging. You can either connect to your browser session via a debug session token that your browser provided, or you can let the CLI intiate a debug session by using `--create_debug_session`. The latter will print a link to stdout that you can open in your browser and the debug session will immediately begin. +`actrun` can bridge your local terminal to the Actionforge web app for visual debugging. You can either connect to your browser session via a debug session token that your browser provided, or you can let the CLI intiate a debug session by using `--create-debug-session`. The latter will print a link to stdout that you can open in your browser and the debug session will immediately begin. ```bash -actrun --create_debug_session ./my_graph.act +actrun --create-debug-session ./my_graph.act ``` diff --git a/cmd/cmd_root.go b/cmd/cmd_root.go index e02dd20..5274ae8 100644 --- a/cmd/cmd_root.go +++ b/cmd/cmd_root.go @@ -7,6 +7,7 @@ import ( "flag" "fmt" "os" + "strings" "github.com/actionforge/actrun-cli/build" "github.com/actionforge/actrun-cli/core" @@ -17,6 +18,7 @@ import ( "github.com/fatih/color" "github.com/inconshreveable/mousetrap" "github.com/spf13/cobra" + "github.com/spf13/pflag" // initialize all nodes _ "github.com/actionforge/actrun-cli/nodes" @@ -140,9 +142,9 @@ var cmdRoot = &cobra.Command{ } if finalCreateDebugSession && finalSessionToken != "" { - return errors.New("both --session_token and --create_debug_session cannot be used together") + return errors.New("both --session-token and --create-debug-session cannot be used together") } else if finalCreateDebugSession && finalGraphFile == "" { - return errors.New("when using --create_debug_session, a graph file must be specified") + return errors.New("when using --create-debug-session, a graph file must be specified") } return nil @@ -200,6 +202,11 @@ func Execute() { } } +// Allow both variations, both --env-file and --env_file will work +func normalizeFlag(f *pflag.FlagSet, name string) pflag.NormalizedName { + return pflag.NormalizedName(strings.ReplaceAll(name, "_", "-")) +} + func init() { flag.Usage = func() { fmt.Print("\n") @@ -214,12 +221,16 @@ func init() { fmt.Print("\n\n") } - cmdRoot.PersistentFlags().StringVar(&flagEnvFile, "env_file", "", "Absolute path to an env file (.env) to load before execution") + // Enable backwards compatibility: allow both --env-file and --env_file + cmdRoot.PersistentFlags().SetNormalizeFunc(normalizeFlag) + cmdRoot.Flags().SetNormalizeFunc(normalizeFlag) + + cmdRoot.PersistentFlags().StringVar(&flagEnvFile, "env-file", "", "Absolute path to an env file (.env) to load before execution") - cmdRoot.Flags().StringVar(&flagConfigFile, "config_file", "", "The config file to use") + cmdRoot.Flags().StringVar(&flagConfigFile, "config-file", "", "The config file to use") 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().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") // disable interspersed flag parsing to allow passing arbitrary flags to graphs. // it stops cobra from parsing flags once it hits positional argument diff --git a/sessions/session.go b/sessions/session.go index a5acf2f..3568851 100644 --- a/sessions/session.go +++ b/sessions/session.go @@ -262,7 +262,7 @@ func RunSessionMode(configFile string, graphFileForDebugSession string, sessionT done := make(chan os.Signal, 1) signal.Notify(done, syscall.SIGINT, syscall.SIGTERM) - // if browser disconnects during a --create_debug_session run, we switch to detached mode + // if browser disconnects during a --create-debug-session run, we switch to detached mode // to ensure the graph finishes execution instead of hanging on a breakpoint. var detachMu sync.Mutex var detachedMode bool @@ -503,7 +503,7 @@ func RunSessionMode(configFile string, graphFileForDebugSession string, sessionT currentDebugOps.cachedState = nil currentDebugOps.Unlock() - // if this was a one-off debug session (initiated by --create_debug_session), exit the process when graph completes + // if this was a one-off debug session (initiated by --create-debug-session), exit the process when graph completes if graphFileForDebugSession != "" { done <- syscall.SIGTERM } diff --git a/tests_e2e/references/reference_app.sh_l10 b/tests_e2e/references/reference_app.sh_l10 index 28f9ff5..77872eb 100644 --- a/tests_e2e/references/reference_app.sh_l10 +++ b/tests_e2e/references/reference_app.sh_l10 @@ -12,11 +12,11 @@ Available Commands: Flags: --concurrency string Enable or disable concurrency - --config_file string The config file to use - --create_debug_session Create a debug session by connecting to the web app - --env_file string Absolute path to an env file (.env) to load before execution + --config-file string The config file to use + --create-debug-session Create a debug session by connecting to the web app + --env-file string Absolute path to an env file (.env) to load before execution -h, --help help for actrun - --session_token string The session token from your browser + --session-token string The session token from your browser -v, --version version for actrun Use "actrun [command] --help" for more information about a command. diff --git a/tests_e2e/references/reference_app.sh_l12 b/tests_e2e/references/reference_app.sh_l12 index b755ac3..7289066 100644 --- a/tests_e2e/references/reference_app.sh_l12 +++ b/tests_e2e/references/reference_app.sh_l12 @@ -25,7 +25,7 @@ stack trace: github.com/actionforge/actrun-cli/core.RunGraphFromFile graph.go:1123 github.com/actionforge/actrun-cli/cmd.cmdRootRun - cmd_root.go:186 + cmd_root.go:188 github.com/spf13/cobra.(*Command).execute command.go:-1 github.com/spf13/cobra.(*Command).ExecuteC @@ -33,7 +33,7 @@ github.com/spf13/cobra.(*Command).ExecuteC github.com/spf13/cobra.(*Command).Execute command.go:-1 github.com/actionforge/actrun-cli/cmd.Execute - cmd_root.go:198 + cmd_root.go:200 main.main main.go:26 runtime.main diff --git a/tests_e2e/references/reference_contexts_env.sh_l26 b/tests_e2e/references/reference_contexts_env.sh_l26 index 99cdd55..993745d 100644 --- a/tests_e2e/references/reference_contexts_env.sh_l26 +++ b/tests_e2e/references/reference_contexts_env.sh_l26 @@ -12,11 +12,11 @@ Available Commands: Flags: --concurrency string Enable or disable concurrency - --config_file string The config file to use - --create_debug_session Create a debug session by connecting to the web app - --env_file string Absolute path to an env file (.env) to load before execution + --config-file string The config file to use + --create-debug-session Create a debug session by connecting to the web app + --env-file string Absolute path to an env file (.env) to load before execution -h, --help help for actrun - --session_token string The session token from your browser + --session-token string The session token from your browser -v, --version version for actrun Use "actrun [command] --help" for more information about a command. diff --git a/tests_e2e/references/reference_dir-walk.sh_l56 b/tests_e2e/references/reference_dir-walk.sh_l56 index 41c320c..ee20662 100644 --- a/tests_e2e/references/reference_dir-walk.sh_l56 +++ b/tests_e2e/references/reference_dir-walk.sh_l56 @@ -46,7 +46,7 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString github.com/actionforge/actrun-cli/core.RunGraphFromFile graph.go:1126 github.com/actionforge/actrun-cli/cmd.cmdRootRun - cmd_root.go:186 + cmd_root.go:188 github.com/spf13/cobra.(*Command).execute command.go:-1 github.com/spf13/cobra.(*Command).ExecuteC @@ -54,7 +54,7 @@ github.com/spf13/cobra.(*Command).ExecuteC github.com/spf13/cobra.(*Command).Execute command.go:-1 github.com/actionforge/actrun-cli/cmd.Execute - cmd_root.go:198 + cmd_root.go:200 main.main main.go:26 runtime.main diff --git a/tests_e2e/references/reference_error_no_output.sh_l8 b/tests_e2e/references/reference_error_no_output.sh_l8 index acd9693..94a8c53 100644 --- a/tests_e2e/references/reference_error_no_output.sh_l8 +++ b/tests_e2e/references/reference_error_no_output.sh_l8 @@ -57,7 +57,7 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString github.com/actionforge/actrun-cli/core.RunGraphFromFile graph.go:1126 github.com/actionforge/actrun-cli/cmd.cmdRootRun - cmd_root.go:186 + cmd_root.go:188 github.com/spf13/cobra.(*Command).execute command.go:-1 github.com/spf13/cobra.(*Command).ExecuteC @@ -65,7 +65,7 @@ github.com/spf13/cobra.(*Command).ExecuteC github.com/spf13/cobra.(*Command).Execute command.go:-1 github.com/actionforge/actrun-cli/cmd.Execute - cmd_root.go:198 + cmd_root.go:200 main.main main.go:26 runtime.main diff --git a/tests_e2e/references/reference_group-port-collision.sh_l13 b/tests_e2e/references/reference_group-port-collision.sh_l13 index d633c83..fcf39aa 100644 --- a/tests_e2e/references/reference_group-port-collision.sh_l13 +++ b/tests_e2e/references/reference_group-port-collision.sh_l13 @@ -37,7 +37,7 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString github.com/actionforge/actrun-cli/core.RunGraphFromFile graph.go:1126 github.com/actionforge/actrun-cli/cmd.cmdRootRun - cmd_root.go:186 + cmd_root.go:188 github.com/spf13/cobra.(*Command).execute command.go:-1 github.com/spf13/cobra.(*Command).ExecuteC @@ -45,7 +45,7 @@ github.com/spf13/cobra.(*Command).ExecuteC github.com/spf13/cobra.(*Command).Execute command.go:-1 github.com/actionforge/actrun-cli/cmd.Execute - cmd_root.go:198 + cmd_root.go:200 main.main main.go:26 runtime.main diff --git a/tests_e2e/references/reference_index.sh_l20 b/tests_e2e/references/reference_index.sh_l20 index c3c7851..64c2561 100644 --- a/tests_e2e/references/reference_index.sh_l20 +++ b/tests_e2e/references/reference_index.sh_l20 @@ -90,7 +90,7 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString github.com/actionforge/actrun-cli/core.RunGraphFromFile graph.go:1126 github.com/actionforge/actrun-cli/cmd.cmdRootRun - cmd_root.go:186 + cmd_root.go:188 github.com/spf13/cobra.(*Command).execute command.go:-1 github.com/spf13/cobra.(*Command).ExecuteC @@ -98,7 +98,7 @@ github.com/spf13/cobra.(*Command).ExecuteC github.com/spf13/cobra.(*Command).Execute command.go:-1 github.com/actionforge/actrun-cli/cmd.Execute - cmd_root.go:198 + cmd_root.go:200 main.main main.go:26 runtime.main diff --git a/tests_e2e/references/reference_run-python-embedded.sh_l13 b/tests_e2e/references/reference_run-python-embedded.sh_l13 index 7af4dc2..f9af3de 100644 --- a/tests_e2e/references/reference_run-python-embedded.sh_l13 +++ b/tests_e2e/references/reference_run-python-embedded.sh_l13 @@ -41,7 +41,7 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString github.com/actionforge/actrun-cli/core.RunGraphFromFile graph.go:1126 github.com/actionforge/actrun-cli/cmd.cmdRootRun - cmd_root.go:186 + cmd_root.go:188 github.com/spf13/cobra.(*Command).execute command.go:-1 github.com/spf13/cobra.(*Command).ExecuteC @@ -49,7 +49,7 @@ github.com/spf13/cobra.(*Command).ExecuteC github.com/spf13/cobra.(*Command).Execute command.go:-1 github.com/actionforge/actrun-cli/cmd.Execute - cmd_root.go:198 + cmd_root.go:200 main.main main.go:26 runtime.main diff --git a/tests_e2e/references/reference_s3_aws_walk.sh_l22 b/tests_e2e/references/reference_s3_aws_walk.sh_l22 index a8d12ad..d070ce1 100644 --- a/tests_e2e/references/reference_s3_aws_walk.sh_l22 +++ b/tests_e2e/references/reference_s3_aws_walk.sh_l22 @@ -50,7 +50,7 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString github.com/actionforge/actrun-cli/core.RunGraphFromFile graph.go:1126 github.com/actionforge/actrun-cli/cmd.cmdRootRun - cmd_root.go:186 + cmd_root.go:188 github.com/spf13/cobra.(*Command).execute command.go:-1 github.com/spf13/cobra.(*Command).ExecuteC @@ -58,7 +58,7 @@ github.com/spf13/cobra.(*Command).ExecuteC github.com/spf13/cobra.(*Command).Execute command.go:-1 github.com/actionforge/actrun-cli/cmd.Execute - cmd_root.go:198 + cmd_root.go:200 main.main main.go:26 runtime.main diff --git a/tests_e2e/references/reference_s3_aws_walk.sh_l44 b/tests_e2e/references/reference_s3_aws_walk.sh_l44 index a8d12ad..d070ce1 100644 --- a/tests_e2e/references/reference_s3_aws_walk.sh_l44 +++ b/tests_e2e/references/reference_s3_aws_walk.sh_l44 @@ -50,7 +50,7 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString github.com/actionforge/actrun-cli/core.RunGraphFromFile graph.go:1126 github.com/actionforge/actrun-cli/cmd.cmdRootRun - cmd_root.go:186 + cmd_root.go:188 github.com/spf13/cobra.(*Command).execute command.go:-1 github.com/spf13/cobra.(*Command).ExecuteC @@ -58,7 +58,7 @@ github.com/spf13/cobra.(*Command).ExecuteC github.com/spf13/cobra.(*Command).Execute command.go:-1 github.com/actionforge/actrun-cli/cmd.Execute - cmd_root.go:198 + cmd_root.go:200 main.main main.go:26 runtime.main diff --git a/tests_e2e/references/reference_select-data.sh_l9 b/tests_e2e/references/reference_select-data.sh_l9 index 2795e04..c6dc69d 100644 --- a/tests_e2e/references/reference_select-data.sh_l9 +++ b/tests_e2e/references/reference_select-data.sh_l9 @@ -97,7 +97,7 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString github.com/actionforge/actrun-cli/core.RunGraphFromFile graph.go:1126 github.com/actionforge/actrun-cli/cmd.cmdRootRun - cmd_root.go:186 + cmd_root.go:188 github.com/spf13/cobra.(*Command).execute command.go:-1 github.com/spf13/cobra.(*Command).ExecuteC @@ -105,7 +105,7 @@ github.com/spf13/cobra.(*Command).ExecuteC github.com/spf13/cobra.(*Command).Execute command.go:-1 github.com/actionforge/actrun-cli/cmd.Execute - cmd_root.go:198 + cmd_root.go:200 main.main main.go:26 runtime.main diff --git a/tests_e2e/references/reference_string-transform.sh_l61 b/tests_e2e/references/reference_string-transform.sh_l61 index 037c2d7..8bc6742 100644 --- a/tests_e2e/references/reference_string-transform.sh_l61 +++ b/tests_e2e/references/reference_string-transform.sh_l61 @@ -57,7 +57,7 @@ github.com/actionforge/actrun-cli/core.RunGraphFromString github.com/actionforge/actrun-cli/core.RunGraphFromFile graph.go:1126 github.com/actionforge/actrun-cli/cmd.cmdRootRun - cmd_root.go:186 + cmd_root.go:188 github.com/spf13/cobra.(*Command).execute command.go:-1 github.com/spf13/cobra.(*Command).ExecuteC @@ -65,7 +65,7 @@ github.com/spf13/cobra.(*Command).ExecuteC github.com/spf13/cobra.(*Command).Execute command.go:-1 github.com/actionforge/actrun-cli/cmd.Execute - cmd_root.go:198 + cmd_root.go:200 main.main main.go:26 runtime.main