diff --git a/cmd/build/cmd_workflow.go b/cmd/build/cmd_workflow.go index cb8b0f4..13f07b8 100644 --- a/cmd/build/cmd_workflow.go +++ b/cmd/build/cmd_workflow.go @@ -33,6 +33,7 @@ func setWorkflowI18n() { func initWorkflowFlags() { releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowPathInput, "path", "", i18n.T("cmd.build.workflow.flag.path")) releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowOutputPathInput, "output-path", "", i18n.T("cmd.build.workflow.flag.output_path")) + releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowOutputPathInput, "output_path", "", i18n.T("cmd.build.workflow.flag.output_path")) releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowOutputPathInput, "output", "", i18n.T("cmd.build.workflow.flag.output")) } @@ -49,7 +50,7 @@ func AddWorkflowCommand(buildCmd *cli.Command) { // buildcmd.AddWorkflowCommand(buildCmd) // runReleaseWorkflow(ctx, "", "") // writes to .github/workflows/release.yml // runReleaseWorkflow(ctx, "ci/release.yml", "") // writes to ./ci/release.yml under the project root -// runReleaseWorkflow(ctx, "", "ci/release.yml") // output-path and output are aliases for the output path input +// runReleaseWorkflow(ctx, "", "ci/release.yml") // output-path, output_path, and output are aliases for the output path input func runReleaseWorkflow(_ context.Context, workflowPathInput, workflowOutputPathInput string) error { projectDir, err := ax.Getwd() diff --git a/cmd/build/cmd_workflow_test.go b/cmd/build/cmd_workflow_test.go index c065e0b..e0fb277 100644 --- a/cmd/build/cmd_workflow_test.go +++ b/cmd/build/cmd_workflow_test.go @@ -35,16 +35,20 @@ func TestBuildCmd_RunReleaseWorkflow_Good(t *testing.T) { pathFlag := releaseWorkflowCmd.Flags().Lookup("path") outputPathFlag := releaseWorkflowCmd.Flags().Lookup("output-path") + outputPathSnakeFlag := releaseWorkflowCmd.Flags().Lookup("output_path") outputFlag := releaseWorkflowCmd.Flags().Lookup("output") assert.NotNil(t, pathFlag) assert.NotNil(t, outputPathFlag) + assert.NotNil(t, outputPathSnakeFlag) assert.NotNil(t, outputFlag) assert.NotEmpty(t, pathFlag.Usage) assert.NotEmpty(t, outputPathFlag.Usage) + assert.NotEmpty(t, outputPathSnakeFlag.Usage) assert.NotEmpty(t, outputFlag.Usage) assert.NotEqual(t, pathFlag.Usage, outputFlag.Usage) assert.NotEqual(t, outputPathFlag.Usage, outputFlag.Usage) + assert.Equal(t, outputPathFlag.Usage, outputPathSnakeFlag.Usage) }) t.Run("writes to a custom relative path", func(t *testing.T) { @@ -145,4 +149,15 @@ func TestBuildCmd_RunReleaseWorkflow_Good(t *testing.T) { assert.Contains(t, content, "workflow_call:") assert.Contains(t, content, "workflow_dispatch:") }) + + t.Run("writes to the output_path alias", func(t *testing.T) { + customPath := "ci/output_path-release.yml" + err := runReleaseWorkflowInDir(projectDir, "", customPath) + require.NoError(t, err) + + content, err := io.Local.Read(ax.Join(projectDir, customPath)) + require.NoError(t, err) + assert.Contains(t, content, "workflow_call:") + assert.Contains(t, content, "workflow_dispatch:") + }) } diff --git a/locales/en.json b/locales/en.json index 375462e..49eb47b 100644 --- a/locales/en.json +++ b/locales/en.json @@ -113,7 +113,7 @@ }, "workflow": { "short": "Generate the release workflow", - "long": "Write the embedded GitHub Actions release workflow into .github/workflows/release.yml, or pass --path/--output-path/--output for a custom location.", + "long": "Write the embedded GitHub Actions release workflow into .github/workflows/release.yml, or pass --path/--output-path/--output_path/--output for a custom location.", "flag": { "path": "Preferred workflow path input.", "output_path": "Preferred explicit workflow output path.",