~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
2 2

[PATCH] todo ticket list: Add status filtering

Details
Message ID
<20240119145101.251924-1-admin@xenrox.net>
DKIM signature
pass
Download raw message
Patch: +13 -2
---
 doc/hut.1.scd | 7 ++++++-
 todo.go       | 8 +++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/doc/hut.1.scd b/doc/hut.1.scd
index 80a49a9..89ba137 100644
--- a/doc/hut.1.scd
+++ b/doc/hut.1.scd
@@ -752,9 +752,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 0c1f568..7615d42 100644
--- a/todo.go
+++ b/todo.go
@@ -280,7 +280,7 @@ func newTodoTicketCommand() *cobra.Command {
}

func newTodoTicketListCommand() *cobra.Command {
	// TODO: Filter by ticket status
	var status string
	run := func(cmd *cobra.Command, args []string) {
		ctx := cmd.Context()
		name, owner, instance, err := getTrackerName(ctx, cmd)
@@ -314,6 +314,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)
			}

@@ -329,6 +333,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: 499ef88754326222b1567261ac6b39b9f2a586ed
--
2.43.0
Details
Message ID
<2o2723iq6dieymgc5vpja5chaeruzsbpccqdlf6rdbhxydgyro@5pauirtn4xln>
In-Reply-To
<20240119145101.251924-1-admin@xenrox.net> (view parent)
DKIM signature
pass
Download raw message
There are of course even more criteria that can be used to filter
tickets like submitter and labels, but I think status is the most
requested one for now.
Before implementing more, I want to work on aligning/improving the
output first. Based on that we can then omit filtering criteria from the
output. So for example if the user is filtering by submitter for one
person, that field no longer should be displayed.

My first idea would be to pass a "filter struct" to the printTicket
function, that contains all the filtering information, but that's just a
first idea.
Details
Message ID
<kDEvEtdj-1B6q3vdsr4RLh9lxKB7yWA9SmYnYRgDl-U8kZItLePtZv5zU1bjFolIFcDF7N_GViYj6dscNvZW9OD8evBn0CwzWBG-wEvUD_Q=@emersion.fr>
In-Reply-To
<20240119145101.251924-1-admin@xenrox.net> (view parent)
DKIM signature
pass
Download raw message
Can we maybe parse the status with todosrht.ParseTicketStatus? To reject
invalid status flags.
Reply to thread Export thread (mbox)