~emersion/hut-dev

todo ticket list: Add status filtering v2 APPLIED

Thorben Günther: 1
 todo ticket list: Add status filtering

 2 files changed, 20 insertions(+), 2 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/hut-dev/patches/49085/mbox | git am -3
Learn more about email & git

[PATCH v2] todo ticket list: Add status filtering Export this patch

---
v2: Check that the status string contains a valid ticket status.

 doc/hut.1.scd |  7 ++++++-
 todo.go       | 15 ++++++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/doc/hut.1.scd b/doc/hut.1.scd
index 0e90942..76d1291 100644
--- a/doc/hut.1.scd
+++ b/doc/hut.1.scd
@@ -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.

diff --git a/todo.go b/todo.go
index 27d7c59..cf62874 100644
--- a/todo.go
+++ b/todo.go
@@ -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
}


base-commit: c096589b7ba247f939886649c5d58b8f1cc95fd4
--
2.43.0
Pushed, thanks!