Skip to content

Commit 1695f5c

Browse files
committed
Change var name to *style-overrides*
1 parent 619c205 commit 1695f5c

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

doc/styles.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@ Beauty is in the eye of the beholder; `cli-tools` makes a default
44
set of choices for what kind of colors and fonts to use
55
for its output, but this can be overridden.
66

7-
The `net.lewisship.cli-tools.styles` contains a dynamic var, `*default-styles*`, that is used by the rest of `cli-tools`
8-
when
9-
formatting output. By overriding or rebinding this var, the fonts can be overridden.
7+
Styles are defined by two vars in namespace `net.lewisship.cli-tools.styles`; each is a
8+
map from a usage name (such as :tool-name-label) to a
9+
[font definition](https://cljdoc.org/d/org.clj-commons/pretty/3.6.7/api/clj-commons.ansi#compose).
1010

11-
The most common to override are:
11+
* `default-styles` are the defaults for all usages
12+
* `*style-overrides*` contains overrides for `default-styles` (and is dynamic)
1213

13-
- :tool-name-label (default :bold.green) used when writing the name of the tool itself
14+
By overriding or rebinding this var, the fonts can be overridden.
15+
16+
The most common usages to override are:
17+
18+
- :tool-name (default :bold.green) used when writing the name of the tool itself
1419
- :command-path (default :bold.green) used when writing the command path
1520

16-
When overriding `*default-styles*`, you can just provide overrides of what's in `default-styles`; anything not found in
17-
the dynamic var is then searched for in the non-dynamic var.
21+
Example:
22+
23+
```clojure
24+
(binding [style/*style-overrides* {:tool-name :inverse.bold}]
25+
(cli-tools/dispatch { ... }))
26+
27+
```

src/net/lewisship/cli_tools/styles.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
:no-command-match :bold
2121
:unknown-term :red})
2222

23-
(def ^:dynamic *default-styles* default-styles)
23+
(def ^:dynamic *style-overrides* default-styles)
2424

2525
(defn style
2626
"Retrieves a style; searches in *default-styles* first and, if not found, then in the default-styles."
2727
[k]
28-
(or (get *default-styles* k)
28+
(or (get *style-overrides* k)
2929
(get default-styles k)))

0 commit comments

Comments
 (0)