cloneit icon indicating copy to clipboard operation
cloneit copied to clipboard

[Feature Request] silent run

Open glitsj16 opened this issue 10 months ago • 1 comments

Thanks for this great piece of software, I've been using it with joy on several (family) Linux machines. Recently I've been scripting a few things and I wonder if there's a way to suppress cloneit's default (colorized) output. A -s or --silent option would be awesome for such use cases.

Regards

glitsj16 avatar Mar 26 '24 19:03 glitsj16

Hello @glitsj16 ,

Good suggestion 👌! We're gonna look into developing that kinda functionality

winterrdog avatar Mar 29 '24 03:03 winterrdog

Hi @glitsj16,

Sorry I've been away from the project for a while, glad to hear it was useful to you. Could you tell me more about your use case? Disabling colorized outputs for normal texts is pretty straightforward, and I can add a -s or --silent option. However, removing the color from the progress bar would require some extra steps. Do you need the progress bar to be non-colored as well?

alok8bb avatar Jul 25 '24 17:07 alok8bb

Hi @alok8bb,

Nice to hear from you. My scripting use case for cloneit tends to be tied into Arch Linux package building. Basically using cloneit to download only the needed files from a git repo and proceeding with the build. Arch extensively uses makepkg in this context, and that already does colorizing of its own. To avoid clashes I'd only need/appreciate what you describe as the straightforward disabling of colorized outputs for normal texts.

Hope this clears things up, regards!

glitsj16 avatar Jul 25 '24 18:07 glitsj16

A common way of dealing with that is the NO_COLOR environment variable: https://no-color.org/. We could add support for this, as well as a flag.

uncenter avatar Jul 25 '24 19:07 uncenter

Hi @uncenter,

I'm familiar with the NO_COLOR env var, so having support for that in cloneit would be awesome. Thanks to the cloneit team to look into this, appreciated.

glitsj16 avatar Jul 25 '24 19:07 glitsj16

However, removing the color from the progress bar would require some extra steps. Do you need the progress bar to be non-colored as well?

I'd be in favor of removing the progress bar altogether (I don't find it particularly helpful, especially as it only ticks upwards for the size of files rather than the total number of files, and I'm not even sure the latter idea is possible), or maybe only display if not in CI (https://crates.io/crates/is_ci)?

uncenter avatar Jul 26 '24 02:07 uncenter

Hi @uncenter,

Hmm true progress bar is kinda useless I just added it for fun but it's good to have some sort of progress indicator. 🤔

About the other issue, I was unfamiliar with the NO_COLOR env variable, but if it works we can certainly add that. Another approach I considered was creating a wrapper function for the .colorize method of the kdam crate. Based on a new flag -s or --silent, we could return the string either with or without colors. For the progress bar, the silent flag can be passed down to the file that creates the progress bar and generate a different type of progress bar—perhaps one that displays progress in a text-only format, also using kdam.

alok8bb avatar Jul 26 '24 09:07 alok8bb

Based on a new flag -s or --silent, we could return the string either with or without colors.

I don't think this is the way it should be done; log verbosity and the presence of colors are not the same thing and should not be controlled by the same flag. Log verbosity should be with a --quiet/-q and/or --verbose/-v, and the presence of colors should be controlled by the aforementioned environment variables.

uncenter avatar Jul 26 '24 11:07 uncenter

I don't think this is the way it should be done; log verbosity and the presence of colors are not the same thing and should not be controlled by the same flag.

I was referring to the text coloring, which is not related to the progress bar. The code uses a simple colorize function from the kdam library to return the colored string. This was an approach I had considered before learning about the NO_COLOR environment variable.

alok8bb avatar Jul 26 '24 11:07 alok8bb

Hello @glitsj16,

NO_COLOR support is merged, now you can run cloneit without colors. 🤠 Much thanks to @uncenter for https://github.com/alok8bb/cloneit/pull/12

alok8bb avatar Jul 27 '24 04:07 alok8bb

I don't think this closes the original issue though about having a --verbose/--quiet flag though btw.

uncenter avatar Jul 27 '24 13:07 uncenter