Instead of
#29049 proposed todo: Add ticket comment (<a href="/~xenrox">~xenrox</a> 4 days ago)
#29037 applied todo: Handle owner in getTrackerID (<a href="/~xenrox">~xenrox</a> 5 days ago)
#29027 applied lists patchset: Implement patch ID completion v2 (<a href="/~xenrox">~xenrox</a> 5 days ago)
we could print aligned fields:
#29049 proposed todo: Add ticket comment (<a href="/~xenrox">~xenrox</a> 4 days ago)
#29037 applied todo: Handle owner in getTrackerID (<a href="/~xenrox">~xenrox</a> 5 days ago)
#29027 applied lists patchset: Implement patch ID completion v2 (<a href="/~xenrox">~xenrox</a> 5 days ago)
Need to figure out what to do with very long field entries.
Thorben Günther referenced this ticket in commit 9c42e4c.
I wanted to align
hut todo ticket list
output and noticed one problem:tabwriter does not handle coloured output very well. It counts the length of the formatting string as if it were displayed in the terminal. I worked around it by making all format strings the same length and while that worked for
hut lists patchset list
, we have a varying amount of coloured labels for each ticket. Right now I see 2-3 options how we could handle this:
- Iterate over all tickets, check which one has the most labels and pad the rest with with "invisible" formatting strings
- Put labels towards the end of the output
- Fork tabwriter and adjust the code as necessary (it is frozen)
Maybe we can use an alternate tabwriter package? e.g.
github.com/juju/ansiterm/tabwriter
sounds like it should handle ANSI escapes properly?
Indeed that looks good and seems to fix my problem.
The tabwriter got removed because it does not work correctly together with our pagination approach (pager). When fetching a new batch of results with a cursor, it could happen that some fields are longer now than in the first batch. Because of that a new formatting approach must be found for at least the following commands:
- ticket list
- patchset list
- * acl list
We could try a combination of:
- Placing long/variable length fields at the end (e.g. patchset subject)
- Declare a maximum length for fields and if it overflows cut off with an indicator. For some fields a maximum length is known beforehand (patchset status) and some are manageable, unless there is an edge case (date, ID: #1, #1000000).