Comments (6)
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.
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.
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.
Flags work for me too. They can always be encapsulated in a shell alias/function π
from diffr.
merged #9. This should allow users to configure the tool output as they like.
from diffr.
Thanks @mookid π
from diffr.
Related Issues (20)
- Improve diffr-lib example HOT 1
- hunk header parsing failure
- Show example of how to configure git to use diffr by default? HOT 3
- Tabs do not play well with --line-numbers
- diffr available on NetBSD HOT 1
- Improve default coloring contrast HOT 8
- Question about highlighting trailing WS HOT 4
- Ignore word-level diff on new or deleted lines HOT 3
- Failing Tests HOT 1
- Inserted code line messes up the downwards coloring
- how to use with git commit --verbose? HOT 1
- Default parameters from environment variable HOT 1
- Native Debian package HOT 2
- [Debian package] Compilation warnings
- [Debian package] Unit tests failing HOT 2
- [Debian package] Missing man page HOT 4
- Doesn't properly handle changed last line followed by "\ No newline at end of file" HOT 3
- Highlighting of title of diffed file HOT 1
- Not encoding-aware, operates on individual bytes HOT 5
- Suggestion: More Precise Coloring Options
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diffr.