(env *execenv.Env)
| 35 | } |
| 36 | |
| 37 | func 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 | |
| 45 | You 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: |
| 47 | git bug status:open sort:edit-desc |
| 48 | |
| 49 | List closed bugs sorted by creation with flags: |
| 50 | git bug --status closed --by creation |
| 51 | |
| 52 | Do a full text search of all bugs: |
| 53 | git bug "foo bar" baz |
| 54 | |
| 55 | Use queries, flags, and full text search: |
| 56 | git 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", |
nothing calls this directly
no test coverage detected