Skip to content
Open
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
10 changes: 9 additions & 1 deletion completers/common/gh_completer/cmd/agentTask_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/gh"
"github.com/spf13/cobra"
)

Expand All @@ -14,7 +15,14 @@ var agentTask_listCmd = &cobra.Command{
func init() {
carapace.Gen(agentTask_listCmd).Standalone()

agentTask_listCmd.Flags().StringP("limit", "L", "", "Maximum number of agent tasks to fetch (default 30)")
agentTask_listCmd.Flags().StringP("jq", "q", "", "Filter JSON output using a jq `expression`")
agentTask_listCmd.Flags().StringSlice("json", nil, "Output JSON with the specified `fields`")
agentTask_listCmd.Flags().StringP("limit", "L", "", "Maximum number of agent tasks to fetch")
agentTask_listCmd.Flags().StringP("template", "t", "", "Format JSON output using a Go template; see \"gh help formatting\"")
agentTask_listCmd.Flags().BoolP("web", "w", false, "Open agent tasks in the browser")
agentTaskCmd.AddCommand(agentTask_listCmd)

carapace.Gen(agentTask_listCmd).FlagCompletion(carapace.ActionMap{
"json": gh.ActionSessionFields().UniqueList(","),
})
}
4 changes: 4 additions & 0 deletions completers/common/gh_completer/cmd/agentTask_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ func init() {
carapace.Gen(agentTask_viewCmd).Standalone()

agentTask_viewCmd.Flags().Bool("follow", false, "Follow agent session logs")
agentTask_viewCmd.Flags().StringP("jq", "q", "", "Filter JSON output using a jq `expression`")
agentTask_viewCmd.Flags().StringSlice("json", nil, "Output JSON with the specified `fields`")
agentTask_viewCmd.Flags().Bool("log", false, "Show agent session logs")
agentTask_viewCmd.PersistentFlags().StringP("repo", "R", "", "Select another repository using the `[HOST/]OWNER/REPO` format")
agentTask_viewCmd.Flags().StringP("template", "t", "", "Format JSON output using a Go template; see \"gh help formatting\"")
agentTask_viewCmd.Flags().BoolP("web", "w", false, "Open agent task in the browser")
agentTaskCmd.AddCommand(agentTask_viewCmd)

carapace.Gen(agentTask_viewCmd).FlagCompletion(carapace.ActionMap{
"json": gh.ActionSessionFields().UniqueList(","),
"repo": gh.ActionOwnerRepositories(gh.HostOpts{}),
})

Expand Down
1 change: 1 addition & 0 deletions completers/common/gh_completer/cmd/browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func init() {
carapace.Gen(browseCmd).Standalone()

browseCmd.Flags().BoolP("actions", "a", false, "Open repository actions")
browseCmd.Flags().Bool("blame", false, "Open blame view for a file")
browseCmd.Flags().StringP("branch", "b", "", "Select another branch by passing in the branch name")
browseCmd.Flags().StringP("commit", "c", "", "Select another commit by passing in the commit SHA, default is the last commit")
browseCmd.Flags().BoolP("no-browser", "n", false, "Print destination URL instead of opening the browser")
Expand Down
8 changes: 5 additions & 3 deletions completers/common/gh_completer/cmd/issue_close.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ func init() {
carapace.Gen(issue_closeCmd).Standalone()

issue_closeCmd.Flags().StringP("comment", "c", "", "Leave a closing comment")
issue_closeCmd.Flags().StringP("reason", "r", "", "Reason for closing: {completed|not planned}")
issue_closeCmd.Flags().String("duplicate-of", "", "Mark as duplicate of another issue by number or URL")
issue_closeCmd.Flags().StringP("reason", "r", "", "Reason for closing: {completed|not planned|duplicate}")
issueCmd.AddCommand(issue_closeCmd)

carapace.Gen(issue_closeCmd).FlagCompletion(carapace.ActionMap{
"comment": action.ActionBody(issue_closeCmd),
"reason": carapace.ActionValues("completed", "not planned"),
"comment": action.ActionBody(issue_closeCmd),
"duplicate-of": action.ActionIssues(issue_closeCmd, action.IssueOpts{Closed: true, Open: true}),
"reason": carapace.ActionValues("completed", "not planned", "duplicate"),
})

carapace.Gen(issue_closeCmd).PositionalCompletion(
Expand Down
26 changes: 22 additions & 4 deletions completers/common/gh_completer/cmd/pr_diff.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package cmd

import (
"path/filepath"
"strings"

"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/completers/common/gh_completer/cmd/action"
"github.com/carapace-sh/carapace/pkg/style"
Expand All @@ -18,16 +21,31 @@ func init() {
carapace.Gen(pr_diffCmd).Standalone()

pr_diffCmd.Flags().String("color", "", "Use color in diff output: {always|never|auto}")
pr_diffCmd.Flags().StringSliceP("exclude", "e", nil, "Exclude files matching glob `patterns` from the diff")
pr_diffCmd.Flags().Bool("name-only", false, "Display only names of changed files")
pr_diffCmd.Flags().Bool("patch", false, "Display diff in patch format")
pr_diffCmd.Flags().BoolP("web", "w", false, "Open the pull request diff in the browser")
prCmd.AddCommand(pr_diffCmd)

carapace.Gen(pr_diffCmd).PositionalCompletion(
action.ActionPullRequests(pr_diffCmd, action.PullRequestOpts{Open: true}),
)

carapace.Gen(pr_diffCmd).FlagCompletion(carapace.ActionMap{
"color": carapace.ActionValues("auto", "never", "always").StyleF(style.ForKeyword),
"exclude": carapace.ActionCallback(func(c carapace.Context) carapace.Action {
args := []string{"pr", "diff", "--name-only"}
if f := pr_diffCmd.Flag("repo"); f.Changed { // TODO use repoverride
args = append(args, "--repo", f.Value.String())
}
args = append(args, c.Args...)
return carapace.ActionExecCommand("gh", args...)(func(output []byte) carapace.Action {
lines := strings.Split(string(output), "\n")
for index, line := range lines {
lines[index] = filepath.Base(line) // full paths don't work as flag value?
}
return carapace.ActionValues(lines[:len(lines)-1]...).StyleF(style.ForPathExt)
})
}).UniqueList(","),
})

carapace.Gen(pr_diffCmd).PositionalCompletion(
action.ActionPullRequests(pr_diffCmd, action.PullRequestOpts{Open: true}),
)
}
1 change: 1 addition & 0 deletions completers/common/gh_completer/cmd/repo_clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var repo_cloneCmd = &cobra.Command{
func init() {
carapace.Gen(repo_cloneCmd).Standalone()

repo_cloneCmd.Flags().Bool("no-upstream", false, "Do not add an upstream remote when cloning a fork")
repo_cloneCmd.Flags().StringP("upstream-remote-name", "u", "", "Upstream remote name when cloning a fork")
repoCmd.AddCommand(repo_cloneCmd)

Expand Down
4 changes: 3 additions & 1 deletion completers/common/gh_completer/cmd/repo_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func init() {
repo_editCmd.Flags().Bool("enable-wiki", false, "Enable wiki in the repository")
repo_editCmd.Flags().StringP("homepage", "h", "", "Repository home page `URL`")
repo_editCmd.Flags().StringSlice("remove-topic", nil, "Remove repository topic")
repo_editCmd.Flags().String("squash-merge-commit-message", "", "The default value for a squash merge commit message: {default|pr-title|pr-title-commits|pr-title-description}")
repo_editCmd.Flags().Bool("template", false, "Make the repository available as a template repository")
repo_editCmd.Flags().String("visibility", "", "Change the visibility of the repository to {public,private,internal}")
repoCmd.AddCommand(repo_editCmd)
Expand All @@ -56,7 +57,8 @@ func init() {
}
return action.ActionRepoTopics(repo_editCmd).UniqueList(",")
}),
"visibility": carapace.ActionValues("public", "private", "internal"),
"squash-merge-commit-message": carapace.ActionValues("default", "pr-title", "pr-title-commits", "pr-title-description"),
"visibility": carapace.ActionValues("public", "private", "internal"),
})

carapace.Gen(repo_editCmd).PositionalCompletion(
Expand Down
24 changes: 24 additions & 0 deletions pkg/actions/tools/gh/session.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package gh

import "github.com/carapace-sh/carapace"

// ActionSessionFields completes session fields
//
// id
// name
func ActionSessionFields() carapace.Action {
return carapace.ActionValues(
"id",
"name",
"state",
"repository",
"user",
"createdAt",
"updatedAt",
"completedAt",
"pullRequestNumber",
"pullRequestUrl",
"pullRequestTitle",
"pullRequestState",
).Tag("session fields")
}