~emersion/hut

5dce3a9ee9d3ebd9569dc263429ef4741a8d1274 — Thorben G√ľnther 2 months ago c096589
todo ticket list: Add status filtering
2 files changed, 20 insertions(+), 2 deletions(-)

M doc/hut.1.scd
M todo.go
M doc/hut.1.scd => doc/hut.1.scd +6 -1
@@ 755,9 755,14 @@ Options are:
	*-l*, *--label* <name>
		Name of the label (required).

*ticket list*
*ticket list* [options...]
	List tickets.

	Options are:

	*-s*, *--status* <string>
		Filter by ticket status.

*ticket show* <ID>
	Display a ticket.


M todo.go => todo.go +14 -1
@@ 281,8 281,15 @@ func newTodoTicketCommand() *cobra.Command {
}

func newTodoTicketListCommand() *cobra.Command {
	// TODO: Filter by ticket status
	var status string
	run := func(cmd *cobra.Command, args []string) {
		if status != "" {
			_, err := todosrht.ParseTicketStatus(status)
			if err != nil {
				log.Fatal(err)
			}
		}

		ctx := cmd.Context()
		name, owner, instance, err := getTrackerName(ctx, cmd)
		if err != nil {


@@ 315,6 322,10 @@ func newTodoTicketListCommand() *cobra.Command {
			}

			for _, ticket := range user.Tracker.Tickets.Results {
				// TODO: filter with API
				if status != "" && !strings.EqualFold(status, string(ticket.Status)) {
					continue
				}
				printTicket(p, &ticket)
			}



@@ 330,6 341,8 @@ func newTodoTicketListCommand() *cobra.Command {
		Args:  cobra.ExactArgs(0),
		Run:   run,
	}
	cmd.Flags().StringVarP(&status, "status", "s", "", "ticket status")
	cmd.RegisterFlagCompletionFunc("status", completeTicketStatus)
	return cmd
}