termgraph icon indicating copy to clipboard operation
termgraph copied to clipboard

A flag to swap labels and values in the input (Unix "uniq" compatibility)

Open maxim-kukushkin opened this issue 4 years ago • 1 comments

Termgraph looks like an amazing tool and it could be really useful for some ad-hoc investigations.

When looking at the logs and other texts it's often useful to run some-command | sort | uniq -c which counts unique entries and prints the list of unique values and the number of occurrences. For example:

     16 alter
     17 create
     15 drop
     12 insert
      8 update

Termgraph would fit nicely into this use case, like some-command | sort | uniq -c | termgraph. The issue is that termgraph always expects the label to go first. Of course in the example above it can be solved with Awk for example (like | awk '{print $2, $1}', however first of all it's an extra step (which reduces usability), and also it makes it problematic if the label contains a space.

That said, it would be awesome to have a CLI flag for termgraph like --values-first, which would tell termgraph to read the value in the first column and use the rest of the line as a label.

It would allow termgraph to be used seamlessly in the example above and also provide extra flexibility in other use cases which can use a similar input format

maxim-kukushkin avatar Dec 09 '21 08:12 maxim-kukushkin

A pull request has been raised to add this functionality: https://github.com/mkaz/termgraph/pull/95

maxim-kukushkin avatar Mar 07 '22 00:03 maxim-kukushkin