Closed KeygenLLC closed 2 years ago
force stats to print as each file completes instead of all at once
This would be great, I agree, but the desktop apps which imageoptim-cli controls don't output that information until they've completed, so this is out of my control.
be able to control what is printed, such as truncating the file path to explicitly state how many parent directories are shown, if any, and the ability to control the color of the output
I have to be honest with you and admit that I don't want to include this feature in the CLI, I don't think anyone else would have a need for it. The best thing to do for something like this would be to pipe the output of imageoptim-cli into another CLI whose job it is to perform all these transformations on the log output.
imageoptim | your-thing --stat-parents 0 --stats time --stat-colors "gray, blue.dim, yellow.bright"
Description
I'd like to know if it's possible to force stats to print as each file completes instead of all at once. If not, then I would like to submit this for a feature, with some additions.
I would also like to be able to control what is printed, such as truncating the file path to explicitly state how many parent directories are shown, if any, and the ability to control the color of the output. While many people may not care, I like to take the time to style output and try to keep things consistent, especially for in-house tools I will use frequently.
An optional addition would be to add 1 more stat: the time it takes to complete each file. This is a personal preference. I just like to know how long it takes for things to complete.
Why? I'm using this with python programs and would like the output to be consistent with the rest of the program. This cli tool is excellent because it blocks, so I can call it with a simple command, let it run, and python will wait until it's done. However, the lack of feedback for each file completion can make one wonder if they are completing, especially when testing or when using large files.
Specifically, I'm using this with an in-house automation system that has multiple shells open at once, those terminal windows have a set width, and the paths are breaking lines making it difficult to read them at a glance. The colors don't jive with my styling, which also makes it more difficult to read than the rest of my output.
Suggested Solution
Additional args to manipulate the output as described above.
For directory output: This could be something like:
--stat-parents 3
or--stat-parents 0
.--dir-parents
or--parents
would also suffice.For people who only care about the end stats or want more granular control over what is displayed, you could also include an option for
--stat-type all
--stat-type stats
--stat-type paths
--stat-type files
--stat-type total
.--stat-type stats
would include just the filename without the directory path plus the KB info. For granular control, they could be combined:--stat-type paths,1,stats,total
For colors:
--stat-colors "color1, color2, color3"
or simply--colors "color1, color2, color3"
or--colors red,blue,yellow
without quotes or spaces. Docs/help could explain the order and available colors. I think using escape characters would make it too cumbersome, so a comma separated list of color names in a string seems reasonable.Including dim or bright versions would be a nice touch, but not a deal breaker. This I would represent with a dot naming of the colors:
--stat-colors "gray, blue.dim, yellow.bright"
. The order should follow the order things are printed. If not enough colors are specified to set everything that's printed, the unspecified ones would remain default. I would suggest that the path and filename be set as separate colors. That's how I personally like to style my output, so the filename pops and I see it right away, and the directory(ies) is there if I need to double check.For completion time: Short timecode would suffice for me using minutes and seconds, such as:
01:24
or00:10
. Could make it an option with--time
or--stats time
.Sum up: If all this seems too cumbersome, I'd be comfortable with setting everything under one flag like
--stats
.--stats "paths, p3, time, gray, gray.dim, blue, gray, yellow.bright"
. As long as things were logical it wouldn't bother me, though I can imagine some would detest such a thing all crammed under one flag.Help Needed
I do not have the skills to code this in the slightest, only enough functional gray matter to make suggestions on how to implement it on the user side, test it, and use it in my projects.