Skip to content

Commit

Permalink
BREAKING CHANGE only under -d:cgCfgToml & in config.toml:[color] section
Browse files Browse the repository at this point in the history
where color specification becomes like the `[render]` section and more
like non-TOML color specs instead of a more awkward TOML list of strings.
Existing TOML users likely need to simplify just 1 file in a user config
(although running under `NO_COLOR=1` is another option).

Also update release notes and the example config.toml file.

Closes #231

If there is popular demand / push back on this change being onerous then
I can take another look, perhaps accepting both old & new syntax, but
the new way seems best.  Please take a look @kaushalmodi
  • Loading branch information
c-blake committed Feb 10, 2024
1 parent f584710 commit e58f95c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
6 changes: 6 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ Version: 1.7.0

- cligen/mslice.initSep allows eliding backslash for special chars: 0, t, n

- BREAKING CHANGE only under -d:cgCfgToml & in config.toml:[color] section
where color specification becomes like the `[render]` section and more
like non-TOML color specs instead of a more awkward TOML list of strings.
Existing TOML users likely need to simplify just 1 file in a user config
(although running under `NO_COLOR=1` is another option).

Version: 1.6.18
---------------
- Add cligen/mslice.within to test if one slice entirely brackets another
Expand Down
7 changes: 3 additions & 4 deletions cligen/clCfgToml.nim
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,18 @@ proc apply(c: var ClCfg, cfgFile: string, plain=false) =
else:
stderr.write(&"{cfgFile}: unknown keyword {k2} in the [{k1}] section\n")
of "color":
stderr.write "toml parsing\n"
if not plain:
for k2, v2 in v1.getTable().pairs:
let val = textAttrOn(v2.getElems().mapIt(it.getStr()))
var on = ""; var off = textAttrOff
let val = v2.getStr()
var on, off: string
if ';' in val:
let c = val.split(';')
if c.len != 2:
stderr.write "[color] values ';' must separate on/off pairs\n"
on = textAttrOn(c[0].strip.split, plain)
off = textAttrOn(c[1].strip.split, plain)
else:
on = textAttrOn(val.split, plain)
on = textAttrOn(val.strip.split, plain); off = textAttrOff
case k2.toLowerAscii()
of "optkeys", "options", "switches", "optkey", "option", "switch":
c.helpAttr["clOptKeys"] = on; c.helpAttrOff["clOptKeys"] = off
Expand Down
14 changes: 7 additions & 7 deletions configs/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
# includes = ["LC_THEME"] # This can define aliases like: colors = "fhot5 = RED"

[color]
switches = ["RED"] # These example colors are likely very ugly to you.
valtype = ["CYAN"] # The full syntax for all these color/attr specs is..
defaultvalue = ["GREEN", "bold"] # .. implemented in `cligen/humanUt.nim:textAttrParse`
description = ["PURPLE"] # .. `cligen/humanUt.nim:attrNames` is a good start.
command = ["bold"] # Command name in one-liners & in multi-cmd tables
doc = ["YELLOW"] # Overall documentation
args = ["RED"] # Positional args in one-liners
switches = "RED" # These example colors are likely very ugly to you.
valtype = "CYAN" # The full syntax for all these color/attr specs is..
defaultvalue = "GREEN bold" # .. implemented in `cligen/humanUt.nim:textAttrParse`
description = "PURPLE" # .. `cligen/humanUt.nim:attrNames` is a good start.
command = "bold" # Command name in one-liners & in multi-cmd tables
doc = "YELLOW" # Overall documentation
args = "RED" # Positional args in one-liners

[render]
singleStar = "italic ; -italic"
Expand Down

0 comments on commit e58f95c

Please sign in to comment.