diff --git a/cmd/cleanup/cleanup.go b/cmd/cleanup/cleanup.go index 3ce0285..e05cf5c 100644 --- a/cmd/cleanup/cleanup.go +++ b/cmd/cleanup/cleanup.go @@ -82,7 +82,6 @@ func listRunsForWorkflow(workflowID int64) ([]*github.WorkflowRun, error) { workflowRun, err := gh.New[github.WorkflowRuns](). Arg("api"). Arg(fmt.Sprintf("/repos/{owner}/{repo}/actions/workflows/%d/runs?per_page=100&page=%d", workflowID, page)). - AppendHostName(). Exec() if err != nil { return nil, err @@ -105,7 +104,8 @@ func findWorkflowByName(name string) (*github.Workflow, error) { var repoWorkflowDefinitions []*github.Workflow page := 1 for { - workflows, err := gh.New[github.Workflows]().Arg("api").Arg(fmt.Sprintf("/repos/{owner}/{repo}/actions/workflows?per_page=100&page=%d", page)).AppendHostName().Exec() + workflows, err := gh.New[github.Workflows]().Arg("api").Arg(fmt.Sprintf("/repos/{owner}/{repo}/actions/workflows?per_page=100&page=%d", page)). + Exec() if err != nil { return nil, err } @@ -133,7 +133,6 @@ func deleteWorkflowRun(workflowID int64) error { Arg("--method"). Arg("DELETE"). ParseOutputJson(false). - AppendHostName(). Exec() return err diff --git a/cmd/dispatch/dispatch.go b/cmd/dispatch/dispatch.go index 40b6e3a..05af4b3 100644 --- a/cmd/dispatch/dispatch.go +++ b/cmd/dispatch/dispatch.go @@ -50,7 +50,7 @@ var dispatchCmd = &cobra.Command{ } } - s := utils.RandomSpinner("Looking for new workflow run\n") + s := utils.RandomSpinner("Looking for new workflow run") newWorkflow, err := utils.TrackNewWorkflowRun(workflowName, func() { _, err := gh.New[any](). diff --git a/cmd/force/force.go b/cmd/force/force.go index d874a69..9441719 100644 --- a/cmd/force/force.go +++ b/cmd/force/force.go @@ -35,7 +35,7 @@ var forceCmd = &cobra.Command{ workflowName = *name } - s := utils.RandomSpinner("Looking for new workflow run\n") + s := utils.RandomSpinner("Looking for new workflow run") newWorkflow, err := utils.TrackNewWorkflowRun(workflowName, func() { git.Commit([]string{"--amend", "--no-edit"}) diff --git a/cmd/push/push.go b/cmd/push/push.go index 4a200fb..2403c03 100644 --- a/cmd/push/push.go +++ b/cmd/push/push.go @@ -35,7 +35,7 @@ If no workflow run as been started, this command will wait indefinite until a ne workflowName = *name } - s := utils.RandomSpinner("Looking for new workflow run\n") + s := utils.RandomSpinner("Looking for new workflow run") newWorkflow, err := utils.TrackNewWorkflowRun(workflowName, func() { git.Push(false) diff --git a/gh/gh.go b/gh/gh.go index 96f1f0a..d772151 100644 --- a/gh/gh.go +++ b/gh/gh.go @@ -12,10 +12,6 @@ import ( type Cmd[T any] struct { // Arguments passed to the command args []string - // Append `--hostname` flag the gh cli command. - // - // Some commands such as `gh workflow run` does not support the `--hostname` flag. Default: false - appendHostName bool // Parse the output of the gh command as json. Default: true parseOutputJson bool } @@ -33,14 +29,6 @@ func (c *Cmd[T]) Arg(a string) *Cmd[T] { return c } -// AppendHostName appends the host name to the gh cli command if the hostname is configured -// -// Default: false -func (c *Cmd[T]) AppendHostName() *Cmd[T] { - c.appendHostName = true - return c -} - // ParseOutputJson toggles parsing the output as json. Defaults: true func (c *Cmd[T]) ParseOutputJson(parse bool) *Cmd[T] { c.parseOutputJson = parse @@ -55,7 +43,7 @@ func (c *Cmd[T]) Exec() (output *T, err error) { if err != nil { return nil, err } - if c.appendHostName && cfg.HostName != "" { + if cfg.HostName != "" { c.args = append(c.args, "--hostname", cfg.HostName) } diff --git a/utils/utils.go b/utils/utils.go index e210871..b49b4ad 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -21,7 +21,10 @@ import ( // // Will return an error if no workflow with `name` is found func GetWorkflowRunByName(name string) (*github.WorkflowRun, error) { - workflowRuns, err := gh.New[github.WorkflowRuns]().Arg("api").Arg("/repos/{owner}/{repo}/actions/runs").AppendHostName().Exec() + workflowRuns, err := gh.New[github.WorkflowRuns](). + Arg("api"). + Arg("/repos/{owner}/{repo}/actions/runs"). + Exec() if err != nil { return nil, err } @@ -75,20 +78,23 @@ func OpenInBrowser(args []string) error { // RandomSpinner creates a random spinner func RandomSpinner(suffix string) *spinner.Spinner { s := spinner.New(spinner.CharSets[rand.Intn(90)], 100*time.Millisecond) - s.Suffix = suffix + s.Suffix = suffix + "\n" return s } // SelectRepoWorkflowName gets all defined workflows in the repo. // -// If there are more than 1 workflow defined, prompt the user to select a workflow. Otherwise return the only workflow +// If there are more than 1 workflow defined, prompt the user to select a workflow. Otherwise, return the only workflow // name in the repo func SelectRepoWorkflowName() (workflowName *string, err error) { // All defined workflows in the repo var repoWorkflowDefinitions []*github.Workflow page := 1 for { - workflows, err := gh.New[github.Workflows]().Arg("api").Arg(fmt.Sprintf("/repos/{owner}/{repo}/actions/workflows?per_page=100&page=%d", page)).AppendHostName().Exec() + workflows, err := gh.New[github.Workflows](). + Arg("api"). + Arg(fmt.Sprintf("/repos/{owner}/{repo}/actions/workflows?per_page=100&page=%d", page)). + Exec() if err != nil { return nil, err }