alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
288 stars 49 forks source link

Suggestion: `--look=` switch #1281

Open jquorning opened 1 year ago

jquorning commented 1 year ago

I suggest refactoring handling of colors and --no-color into a new command line switch:

--look=<theme> where theme:

mosteo commented 1 year ago

Thanks for the suggestion. More generally, there are some defaults that are now hardcoded that we may want to make overridable (possibly using our config mechanism) and this could be a good fit.

jquorning commented 1 year ago

As a start is suggest a HTML TTY driver package:

If that sounds like a plan you may assign me the issue.

mosteo commented 1 year ago

I agree on the spirit of the idea, but I don't think we need to go with HTML. We basically have a series of predefined styles (crate name, version, code, url, emphasized, etc.) that we are already using mostly consistently. We would need a way to redefine these styles.

I think if we were to adopt an extra formatting library, we would end duplicating the boiler plate. We now have, for example:

Put_line ("Crate " & TTY.Name (Crate_Name) & " not found")

and going to tags we'd have

Put_line (TTY.Format ("Crate <name>" & Crate_Name & "</name> not found")

Although if at some point we wanted to go multilingual, having a way to completely excise strings from code would be necessary, and in that case I can see it working like that.

Fabien-Chouteau commented 1 year ago

Indeed the best solution right now is to introduce those themes in https://github.com/alire-project/alire/blob/master/src/alire/alire-utils-tty.ads

and have a configuration value to change the default.