~emersion/hut-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH v2] todo ticket list: Add status filtering

Details
Message ID
<20240131201410.310713-1-admin@xenrox.net>
DKIM signature
pass
Download raw message
Patch: +20 -2
---
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
Details
Message ID
<przqwj8c3IkfyMITk5wLgrNDiuEiB7KKtWoYw5zRl63SJhR3N18-RPJeT1ZINEBOUca42rbJVDZa7MU8l_lybw3shiyHKQcV7hqo0lmmc8c=@emersion.fr>
In-Reply-To
<20240131201410.310713-1-admin@xenrox.net> (view parent)
DKIM signature
pass
Download raw message
Pushed, thanks!
Reply to thread Export thread (mbox)