feat: filtering and ordering in the bug list

Labels: area/cli kind/feature

Timeline

Klaus Alexander Seistrup (kseistrup) opened

It would be nice – and make it easier to get an overview of what needs to be done – to be able to hide closed issues when doing a git bug ls.

Michael Muré (MichaelMure) commented

In a more general sense, git-bug needs filtering and ordering in the bug list.

For performance, that also means having a sort of cache serialized on disk with a subset of values for each bug (creation/edit date, status, author, ...).

Michael Muré (MichaelMure) changed the title from feat: filtering and ordering in the bug list to feat: filtering and ordering in the bug list

Michael Muré (MichaelMure) added label enhancement

Michael Muré (MichaelMure) added label Core

Michael Muré (MichaelMure) commented

Alright, there is now a whole new layer that maintain in memory and on disk an excerpt of each bug (creation/edit time, status ...). This layer also provide a fast sorting without having to load all bugs in memory.

Next steps:

  • add the filtering
  • expose the filtering/sorting in the graphql API
  • add the last mile code to have these feature in each UI

Michael Muré (MichaelMure) commented

Now the big question is, how this filtering/ordering should be done in the CLI ? I see two options:

  • regular CLI flags: git bug ls -state open -sort comments -order asc

  • a micro language, as Github do: git bug ls "is:open sort:comments-desc"

On Github, we have the convenience of having a web UI with dropdown and buttons that write this query, while still having the power to edit it manually. Not so much in a CLI interface.

It would be neat to have a common query format for all UIs though.

I'm inclined to go for the first option as the termui will give the "easy to use UI" in a terminal, leaving the CLI for automated interaction or simple manual tasks.

Michael Muré (MichaelMure) commented

Also, a micro language can be added later.

Michael Muré (MichaelMure) commented

I had a burst of motivation and implemented a micro query DSL for filtering/sorting.

Documentation

It's already available in git bug ls, minus a parsing bug with quoted qualifer (label:"Good first issue").

Michael Muré (MichaelMure) commented

git bug ls now support expressing a query with both the DSL and regular flags:

git-bug ls

List bugs

Synopsis

Display a summary of each bugs.

You can pass an additional query to filter and order the list. This query can be expressed either with a simple query language or with flags.

git-bug ls [<query>] [flags]

Examples

List open bugs sorted by last edition with a query:
git bug ls "status:open sort:edit-desc"

List closed bugs sorted by creation with flags:
git bug ls --status closed --by creation

Options

  -s, --status strings     Filter by status. Valid values are [open,closed]
  -a, --author strings     Filter by author
  -l, --label strings      Filter by label
  -n, --no strings         Filter by absence of something. Valid values are [label]
  -b, --by string          Sort the results by a characteristic. Valid values are [id,creation,edit] (default "creation")
  -d, --direction string   Select the sorting direction. Valid values are [asc,desc] (default "asc")
  -h, --help               help for ls

Michael Muré (MichaelMure) commented

Only things left:

  • graphql api
  • termui integration

Michael Muré (MichaelMure) commented

And those are done as well ! That was a journey in itself ...

Michael Muré (MichaelMure) closed the bug

sudoforge removed label enhancement

sudoforge removed label Core

sudoforge added label area/cli

sudoforge added label kind/feature