From 185f6242b957f1167adc183f9c7ee7e414fdd479 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Mon, 12 Apr 2021 13:58:40 -0500 Subject: [PATCH 1/5] make gh actions output Real --- pkg/cmd/actions/actions.go | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/pkg/cmd/actions/actions.go b/pkg/cmd/actions/actions.go index f0e3509a4..ac5a4208b 100644 --- a/pkg/cmd/actions/actions.go +++ b/pkg/cmd/actions/actions.go @@ -21,7 +21,7 @@ func NewCmdActions(f *cmdutil.Factory) *cobra.Command { cmd := &cobra.Command{ Use: "actions", Short: "Learn about working with GitHub actions", - Args: cobra.ExactArgs(0), + Long: actionsExplainer(nil, false), Hidden: true, Run: func(cmd *cobra.Command, args []string) { actionsRun(opts) @@ -34,15 +34,20 @@ func NewCmdActions(f *cmdutil.Factory) *cobra.Command { return cmd } -func actionsRun(opts ActionsOptions) { - cs := opts.IO.ColorScheme() - fmt.Fprint(opts.IO.Out, heredoc.Docf(` - Welcome to GitHub Actions on the command line. +func actionsExplainer(cs *iostreams.ColorScheme, color bool) string { + header := "Welcome to GitHub Actions on the command line." + runHeader := "Interacting with workflow runs" + workflowHeader := "Interacting with workflow files" + if color { + header = cs.Bold(header) + runHeader = cs.Bold(runHeader) + workflowHeader = cs.Bold(workflowHeader) + } - This part of gh is in beta and subject to change! + return fmt.Sprintf(heredoc.Docf(` + %s - To follow along while we get to GA, please see this - tracking issue: https://github.com/cli/cli/issues/2889 + gh integrates with Actions to help you manage runs and workflows. %s gh run list: List recent workflow runs @@ -50,12 +55,23 @@ func actionsRun(opts ActionsOptions) { gh run watch: Watch a workflow run while it executes gh run rerun: Rerun a failed workflow run + To see more help, run 'gh help run ' + %s gh workflow list: List all the workflow files in your repository gh workflow enable: Enable a workflow file gh workflow disable: Disable a workflow file gh workflow run: Trigger a workflow_dispatch run for a workflow file + + To see more help, run 'gh help workflow ' + + For more in depth help including examples, see online documentation at: + https://docs.github.com/en/actions/guides/managing-github-actions-with-github-cli `, - cs.Bold("Interacting with workflow runs"), - cs.Bold("Interacting with workflow files"))) + header, runHeader, workflowHeader)) +} + +func actionsRun(opts ActionsOptions) { + cs := opts.IO.ColorScheme() + fmt.Fprintf(opts.IO.Out, actionsExplainer(cs, true)) } From cb03a3a7761e092abf96a16f05c70347c76d9abc Mon Sep 17 00:00:00 2001 From: vilmibm Date: Mon, 12 Apr 2021 14:17:05 -0500 Subject: [PATCH 2/5] linter appeasement --- pkg/cmd/actions/actions.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/actions/actions.go b/pkg/cmd/actions/actions.go index ac5a4208b..40c93f1ae 100644 --- a/pkg/cmd/actions/actions.go +++ b/pkg/cmd/actions/actions.go @@ -44,7 +44,7 @@ func actionsExplainer(cs *iostreams.ColorScheme, color bool) string { workflowHeader = cs.Bold(workflowHeader) } - return fmt.Sprintf(heredoc.Docf(` + return heredoc.Docf(` %s gh integrates with Actions to help you manage runs and workflows. @@ -67,11 +67,10 @@ func actionsExplainer(cs *iostreams.ColorScheme, color bool) string { For more in depth help including examples, see online documentation at: https://docs.github.com/en/actions/guides/managing-github-actions-with-github-cli - `, - header, runHeader, workflowHeader)) + `, header, runHeader, workflowHeader) } func actionsRun(opts ActionsOptions) { cs := opts.IO.ColorScheme() - fmt.Fprintf(opts.IO.Out, actionsExplainer(cs, true)) + fmt.Fprintln(opts.IO.Out, actionsExplainer(cs, true)) } From 9a0193b77c21f72e7ce4f0d1e34b46558eafe0a3 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Mon, 12 Apr 2021 14:28:58 -0500 Subject: [PATCH 3/5] add gh run download --- pkg/cmd/actions/actions.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/cmd/actions/actions.go b/pkg/cmd/actions/actions.go index 40c93f1ae..b93e1171a 100644 --- a/pkg/cmd/actions/actions.go +++ b/pkg/cmd/actions/actions.go @@ -50,18 +50,19 @@ func actionsExplainer(cs *iostreams.ColorScheme, color bool) string { gh integrates with Actions to help you manage runs and workflows. %s - gh run list: List recent workflow runs - gh run view: View details for a workflow run or one of its jobs - gh run watch: Watch a workflow run while it executes - gh run rerun: Rerun a failed workflow run + gh run list: List recent workflow runs + gh run view: View details for a workflow run or one of its jobs + gh run watch: Watch a workflow run while it executes + gh run rerun: Rerun a failed workflow run + gh run download: Download artifacts generated by runs To see more help, run 'gh help run ' %s - gh workflow list: List all the workflow files in your repository - gh workflow enable: Enable a workflow file - gh workflow disable: Disable a workflow file - gh workflow run: Trigger a workflow_dispatch run for a workflow file + gh workflow list: List all the workflow files in your repository + gh workflow enable: Enable a workflow file + gh workflow disable: Disable a workflow file + gh workflow run: Trigger a workflow_dispatch run for a workflow file To see more help, run 'gh help workflow ' From 2b17de80f67b4a6cdbfdd2825ed810c4aa0475c4 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Mon, 12 Apr 2021 14:38:45 -0500 Subject: [PATCH 4/5] workflow view --- pkg/cmd/actions/actions.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/cmd/actions/actions.go b/pkg/cmd/actions/actions.go index b93e1171a..f53cdf3ff 100644 --- a/pkg/cmd/actions/actions.go +++ b/pkg/cmd/actions/actions.go @@ -60,6 +60,7 @@ func actionsExplainer(cs *iostreams.ColorScheme, color bool) string { %s gh workflow list: List all the workflow files in your repository + gh workflow view: View details for a workflow file gh workflow enable: Enable a workflow file gh workflow disable: Disable a workflow file gh workflow run: Trigger a workflow_dispatch run for a workflow file From c724070cbe92b806e5cfdc6125d880d1f399d09a Mon Sep 17 00:00:00 2001 From: vilmibm Date: Mon, 12 Apr 2021 15:51:00 -0500 Subject: [PATCH 5/5] just check nil --- pkg/cmd/actions/actions.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/actions/actions.go b/pkg/cmd/actions/actions.go index f53cdf3ff..5be2df305 100644 --- a/pkg/cmd/actions/actions.go +++ b/pkg/cmd/actions/actions.go @@ -21,7 +21,7 @@ func NewCmdActions(f *cmdutil.Factory) *cobra.Command { cmd := &cobra.Command{ Use: "actions", Short: "Learn about working with GitHub actions", - Long: actionsExplainer(nil, false), + Long: actionsExplainer(nil), Hidden: true, Run: func(cmd *cobra.Command, args []string) { actionsRun(opts) @@ -34,11 +34,11 @@ func NewCmdActions(f *cmdutil.Factory) *cobra.Command { return cmd } -func actionsExplainer(cs *iostreams.ColorScheme, color bool) string { +func actionsExplainer(cs *iostreams.ColorScheme) string { header := "Welcome to GitHub Actions on the command line." runHeader := "Interacting with workflow runs" workflowHeader := "Interacting with workflow files" - if color { + if cs != nil { header = cs.Bold(header) runHeader = cs.Bold(runHeader) workflowHeader = cs.Bold(workflowHeader) @@ -74,5 +74,5 @@ func actionsExplainer(cs *iostreams.ColorScheme, color bool) string { func actionsRun(opts ActionsOptions) { cs := opts.IO.ColorScheme() - fmt.Fprintln(opts.IO.Out, actionsExplainer(cs, true)) + fmt.Fprintln(opts.IO.Out, actionsExplainer(cs)) }