Git Product home page Git Product logo

Comments (6)

mookid avatar mookid commented on June 3, 2024

The implementation is not a problem, this is all handled by the termcolor crate.

Note that all color options will not work (or have the same effect) on all OSs, and I would like to keep the default configuration to be something that works everywhere (in particular on Windows).

The main issue I see is what command line arguments to provide. What do other unix tools do?
Let's try to find a good enough design: few arguments, readable color syntax, possibility to handle all kinds of attributes supported on console APIs.

For reference:
https://docs.rs/termcolor/1.0.5/src/termcolor/lib.rs.html#1413-1419

from diffr.

ericfreese avatar ericfreese commented on June 3, 2024

What would you think of a config file in $XDG_CONFIG_HOME? It could be a simple key value pair where the key specifies the thing to be styled and the value specifies the style for it. Could have an alternate API as well where those keys/values are provided/overriden by either environment variables or arguments.

Could possibly use git for inspiration? See the color section under https://manpages.debian.org/jessie-backports/git-man/git-config.1.en.html#Values

The value for a variable that takes a color is a list of colors (at most two, one for foreground and one for background) and attributes (as many as you want), separated by spaces.
The basic colors accepted are normal, black, red, green, yellow, blue, magenta, cyan and white. The first color given is the foreground; the second is the background.
Colors may also be given as numbers between 0 and 255; these use ANSI 256-color mode (but note that not all terminals may support this). If your terminal supports it, you may also specify 24-bit RGB values as hex, like #ff0ab3.
The accepted attributes are bold, dim, ul, blink, reverse, italic, and strike (for crossed-out or "strikethrough" letters). The position of any attributes with respect to the colors (before, after, or in between), doesn’t matter. Specific attributes may be turned off by prefixing them with no or no- (e.g., noreverse, no-ul, etc).
For git’s pre-defined color slots, the attributes are meant to be reset at the beginning of each item in the colored output. So setting color.decorate.branch to black will paint that branch name in a plain black, even if the previous thing on the same output line (e.g. opening parenthesis before the list of branch names in log --decorate output) is set to be painted with bold or some other attribute. However, custom log formats may do more complicated and layered coloring, and the negated forms may be useful there.

from diffr.

mookid avatar mookid commented on June 3, 2024

What would you think of a config file in $XDG_CONFIG_HOME? It could be a simple key value pair where the key specifies the thing to be styled and the value specifies the style for it. Could have an alternate API as well where those keys/values are provided/overriden by either environment variables or arguments.

Could possibly use git for inspiration? See the color section under https://manpages.debian.org/jessie-backports/git-man/git-config.1.en.html#Values

Thanks for the input! I will take a look at how some projects provide that info among other unix tools, but that spec is quite attractive. Another alternative would be ripgrep format.

I was more thinking about process flags with arguments rather than (yet another) config file

  • mostly because I use diffr exclusively from git (so having a somewhat hairy invocation in .gitconfig is ok, it is a once-only thing)
  • because it is easy to implement with clap: I don't have a choice of config file location to make

And a config file can still be added later.

from diffr.

ericfreese avatar ericfreese commented on June 3, 2024

Flags work for me too. They can always be encapsulated in a shell alias/function πŸ‘

from diffr.

mookid avatar mookid commented on June 3, 2024

merged #9. This should allow users to configure the tool output as they like.

from diffr.

ericfreese avatar ericfreese commented on June 3, 2024

Thanks @mookid πŸŽ‰

from diffr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.