MCPcopy Index your code
hub / github.com/git-bug/git-bug / NewBugCommand

Function NewBugCommand

commands/bug/bug.go:37–122  ·  view source on GitHub ↗
(env *execenv.Env)

Source from the content-addressed store, hash-verified

35}
36
37func NewBugCommand(env *execenv.Env) *cobra.Command {
38 options := bugOptions{}
39
40 cmd := &cobra.Command{
41 Use: "bug [QUERY]",
42 Short: "List bugs",
43 Long: `Display a summary of each bugs.
44
45You can pass an additional query to filter and order the list. This query can be expressed either with a simple query language, flags, a natural language full text search, or a combination of the aforementioned.`,
46 Example: `List open bugs sorted by last edition with a query:
47git bug status:open sort:edit-desc
48
49List closed bugs sorted by creation with flags:
50git bug --status closed --by creation
51
52Do a full text search of all bugs:
53git bug "foo bar" baz
54
55Use queries, flags, and full text search:
56git bug status:open --by creation "foo bar" baz
57`,
58 PreRunE: execenv.LoadBackend(env),
59 RunE: execenv.CloseBackend(env, func(cmd *cobra.Command, args []string) error {
60 options.outputFormatChanged = cmd.Flags().Changed("format")
61 return runBug(env, options, args)
62 }),
63 ValidArgsFunction: completion.Ls(env),
64 }
65
66 flags := cmd.Flags()
67 flags.SortFlags = false
68
69 flags.StringSliceVarP(&options.statusQuery, "status", "s", nil,
70 "Filter by status. Valid values are [open,closed]")
71 cmd.RegisterFlagCompletionFunc("status", completion.From([]string{"open", "closed"}))
72 flags.StringSliceVarP(&options.authorQuery, "author", "a", nil,
73 "Filter by author")
74 flags.StringSliceVarP(&options.metadataQuery, "metadata", "m", nil,
75 "Filter by metadata. Example: github-url=URL")
76 cmd.RegisterFlagCompletionFunc("author", completion.UserForQuery(env))
77 flags.StringSliceVarP(&options.participantQuery, "participant", "p", nil,
78 "Filter by participant")
79 cmd.RegisterFlagCompletionFunc("participant", completion.UserForQuery(env))
80 flags.StringSliceVarP(&options.actorQuery, "actor", "A", nil,
81 "Filter by actor")
82 cmd.RegisterFlagCompletionFunc("actor", completion.UserForQuery(env))
83 flags.StringSliceVarP(&options.labelQuery, "label", "l", nil,
84 "Filter by label")
85 cmd.RegisterFlagCompletionFunc("label", completion.Label(env))
86 flags.StringSliceVarP(&options.titleQuery, "title", "t", nil,
87 "Filter by title")
88 flags.StringSliceVarP(&options.noQuery, "no", "n", nil,
89 "Filter by absence of something. Valid values are [label]")
90 cmd.RegisterFlagCompletionFunc("no", completion.Label(env))
91 flags.StringVarP(&options.sortBy, "by", "b", "creation",
92 "Sort the results by a characteristic. Valid values are [id,creation,edit]")
93 cmd.RegisterFlagCompletionFunc("by", completion.From([]string{"id", "creation", "edit"}))
94 flags.StringVarP(&options.sortDirection, "direction", "d", "asc",

Callers

nothing calls this directly

Calls 15

LoadBackendFunction · 0.92
CloseBackendFunction · 0.92
LsFunction · 0.92
FromFunction · 0.92
UserForQueryFunction · 0.92
LabelFunction · 0.92
runBugFunction · 0.85
newBugDeselectCommandFunction · 0.85
newBugSelectCommandFunction · 0.85
newBugCommentCommandFunction · 0.85
newBugLabelCommandFunction · 0.85
newBugNewCommandFunction · 0.85

Tested by

no test coverage detected