dspinellis/git-issue

Add long listing format

dspinellis opened this issue · 11 comments

  • Fields that shall be included:
    • issue-id
    • open/closed
    • creation time
    • modification time
    • milestone
    • assignee(s)
    • tag(s)
    • description
  • A -l option shall trigger the long format and the letters iocmMATD as the option's argument shall be used to specify which fields to list.
  • A -o option with one of the preceding letters shall specify the (ascending) sort order.
  • A -r option shall reverse the sort order.
  • The variable-width fields (milestone, assignees, tags, description) shall be preceded by the letter MATD followed by a colon and a space, e.g. M: version-2.
  • A C argument to the -l option shall specify CSV output format. (Multiple elements of the same field will be separated by ;.)
  • A J argument to the -l option shall specify JSON output format.

See also issue #37.

I've started work on this feature. Currently, the following are implemented:

  • -l option with mandatory argument [icMATD] (issue id, creation time, Milestone, Assignee, Tag, Description, one or more of the above).

  • optional -o and -r options as described above

An example call would thus be: git issue list -l icTD -o c -r . This would display all (open) issues in reverse chronological order(newest to oldest), showing the fields (issue id, creation time, Tags, Description).

Feedback and testing / bug reports would be welcome. Here's my repository: https://github.com/vyrondrosos/git-issue

Nice! Any reason we're not following the Git convention of specifying fields with format arguments? Example: -l '%i: %M'

That's a nice suggestion, hadn't considered that actually. I'll look into implementing git-like syntax, it's more flexible anyway than just specifying the fields, even if a little more cumbersome. Possibly with some presets for convenience( like Git's --pretty=<format> ).

Happy to hear you like it. To implement it, you could generate each record as follows:

echo "$format" | 
sed "
s/\\n/\n/g
s/%i/$ID/g
s/%M/$MESSAGE/g
...
"

Update:

The format string now looks like this:

git issue list -l 'Issue %i was created on %c and is tagged: %T %nDescription: %D' -o '%c' -r

(I opted for %n instead of \n since that's what git show uses)

Excellent! Following Git's format specifiers is the way to go.

Indeed it is. I also implemented a preset -p option, e.g
git issue list -l short -p prints the ID, Date, Tags and Description for each issue. Options are also oneline and full.

I updated the docs to match, although I'm not sure if I got the formatting right. Please let me know if there's anything else to be done before submitting a PR.

Nice! Can't you set the preset behavior when a -l format is specified, without requiring an additional -p flag?

Sure thing, that's a quick fix. Done.

Please submit the PR.

Implemented with b12398f.