Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parser-friendly output mode #135

Open
maximbaz opened this issue Aug 7, 2020 · 0 comments
Open

Add parser-friendly output mode #135

maximbaz opened this issue Aug 7, 2020 · 0 comments

Comments

@maximbaz
Copy link

maximbaz commented Aug 7, 2020

Hi,

First of all, love the tool, awesome idea!

I got interested to use progress as a framework for building other tools on top of it, specifically an indicator for my status panel that would show the currently running operations, and I found it quite difficult to parse the values out of the progress command. Hence this feature request 🙂

Just to give you an example, suppose I want to display on my status panel just the command name (cp, mv, etc.) and the current progress percentage, e.g. cp 73% rsync 25%. In addition, I want to exclude certain commands (e.g. gpg) and I want to exclude 0% and 100% values.

Here's the current code that is capable of doing that:

progress -q | sed 's/\[[^]]*\] //g' | awk 'BEGIN { ORS=" " } NR%3==1 { op=$1 } NR%3==2 { pct=($1+0); if (op != "gpg" && pct > 0 && pct < 100) { print op, $1 } }'

Not very readable, and took time to come up with.

What made it difficult to parse was this:

  • Multiple lines per entry (specifically, three lines)
  • No easy separator between columns (the most obvious idea is to split on space, but e.g. PID can be [12345] and [ 1234])

I stumbled upon this blog post, and I must say this would probably be ideal if progress had a --json flag, which would output everything in JSON format, which is standard, predictable, and super easy to parse with jq.

I also saw #131 and initially got excited by it, but then I realized it doesn't print all the fields, so it isn't really a solution.

What do you think about --json option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant