~emersion/hut#16: 
Align output fields

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.

Status
REPORTED
Submitter
~emersion
Assigned to
No-one
Submitted
2 years ago
Updated
9 months ago
Labels
enhancement

~emersion 2 years ago

Thorben G√ľnther referenced this ticket in commit 9c42e4c.

~xenrox 2 years ago

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:

  1. Iterate over all tickets, check which one has the most labels and pad the rest with with "invisible" formatting strings
  2. Put labels towards the end of the output
  3. Fork tabwriter and adjust the code as necessary (it is frozen)

~emersion 2 years ago

Maybe we can use an alternate tabwriter package? e.g. github.com/juju/ansiterm/tabwriter sounds like it should handle ANSI escapes properly?

~xenrox 2 years ago

Indeed that looks good and seems to fix my problem.

~xenrox 9 months ago

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).
Register here or Log in to comment, or comment via email.