Repository navigation
Commit eabbe2b
authored
feat(cli): print the logo in block characters as the startup banner (#631)
## Motivation
The startup banner becomes the ethlambda logo, drawn with block
characters from the code page 437 set (`█ ▀ ▄ ░`):
```
█ ▄
▀▀ █ ▄█▀▀▀▄▄ ▄ ▄
▄▄ ▀▀ ▄ ░░░██░░░░░▀▄░░░ ▀ █ ░
█░░ ▄ ░░ ░░░▀▀▀░░░ ░░ █ ▄ ░░░
▄██░ ▀ ░▄█▀░░█▀▀▀█░░▀█▄░ █ ▄ ░▄▄▄
█▀▀ ▀▀ ░░█▀▄▄░░▄▄▄░░▄▄▀█░░ ▀ ▀ ▀▀█
█░░ ▄ ▄▄ ░░ █░░█▄▀░▄░▀▄█░░█ ░░ ▄▄ ░░█
█░░░ ░▀▀░░ █▄░░█▄▀█▀▄█░░▄█ ░░▀▀█ ░░░█
░██▄░░░░ ▄▄▄░ ▀█▄▄█▄░▄█▄▄█▀ ▄▄▄ ░░░░▄██░
▀█░▄▄▀▀░░░░░ ▄░▀▀░░░▀▀░▄ ░░░░░▀▀ ▄▄█▀
██▀░░░░░▄░░░█ ░░▀▀▀░░ █░░░░░░░░ ░▀█
▄██░░░░▄▄ █░░░░█▄ ▄ ▄ ▄█░░░ ███░ ░░▀█▄
█▀░░░▄█▀ █░░▄░░▀█▄▄▄█▀░░░░░ ░░ █▄░░░░▀
▀░░░██ ▄█▀░░▄ ▄ ░▄░░░▀▄ ██░░░░
░░░▀█▄ █▀░░▄█▀░▄▀ ░▄█ ░▄░░▀ ▄ ▀░░░░
░██▄░ █░░▄█ ░█▄ ██▄ ██░░ ██░░░░
▀▄ ░░█░ ░░▀█▄ ░█░ ░█ █▀░░ ██░░
▀▄░▄█▀ ▄ ░░██ █░ ▄▀▀█░░ ▀█▄░░ ▄
▀▀ ▀▀█▀ █ ▄▄█▀ ▄▀▄█ █▄ ▄ ▀███▀
▀ ▄ ▀ ▀▀ ▄ ▀▀ ▀▀▄ ▀▀ ░ ▀ ▀
█▀▀▀▀█▀▀▀█▀██▀█▀█████▀▀██▀███▀█▀▀▀██▀▀▀███▀▀██
█ ▀▀███ ██ ▀▀ █ ████ ▀▀ █ ▄▀▄ █ ▀▀▄█ ██ █ ▀▀ █
█ ▀▀▀██ ██ ██ █ ▀▀▀█ ██ █ ███ █ ▀▀▄█ ▀▀▄█ ██ █
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
```
Those characters only render on a terminal that decodes UTF-8, and a
process cannot ask its terminal which encoding it uses. So the banner
follows the locale the terminal advertises, and anything that is not a
UTF-8 locale keeps printing the current ASCII wordmark.
## Changes
- `bin/ethlambda/assets/ethlambda_banner.txt`: the new logo.
- `bin/ethlambda/assets/ethlambda_banner_ascii.txt`: the previous
banner, moved out of `main.rs` unchanged.
- `bin/ethlambda/src/banner.rs`: embeds both with `include_str!`, and
`for_locale()` picks one.
- The first non-empty of `LC_ALL`, `LC_CTYPE` and `LANG` decides, which
is POSIX precedence. It counts as UTF-8 when it contains `utf-8` or
`utf8`, in any case. With none of them set the locale is `C`, so ASCII.
- Values are read with `env::var_os`: a set variable whose bytes are not
valid Unicode still takes precedence, where `env::var` would skip it and
let a lower-ranked variable decide.
- `bin/ethlambda/src/main.rs`: drops the `ASCII_ART` constant and prints
`banner::for_locale()`.
## Behavior
- On a non-UTF-8 locale the output is byte for byte what it was: a blank
line, the wordmark, a blank line.
- The Docker image does not set `LANG`, so containers keep printing the
ASCII banner unless run with `-e LANG=C.UTF-8`.
- The choice is made by the process writing the output. `docker logs` or
a log file read somewhere else shows whatever the writer's locale
picked.
## Tests
- 8 unit tests in `banner::tests`: variable precedence, empty values,
non-UTF-8 encodings, a non-Unicode `LC_ALL`, and that the fallback file
is pure ASCII. They pass the variables in through a closure, so they
never touch the process environment.
- Ran the binary with `LANG=en_US.UTF-8`, `LANG=C` and no `LANG`: the
block logo, then the ASCII wordmark both times.
## ✅ Verification Checklist
- [x] `cargo fmt --all -- --check`: clean
- [x] `cargo clippy -p ethlambda --profile release-fast --all-targets --
-D warnings`: clean. Scoped to this crate, since the change touches
nothing else
- [x] `cargo test -p ethlambda --profile release-fast --bins banner`: 8
passing. The full `make test` was not run1 parent ebbbde7 commit eabbe2b
4 files changed
Lines changed: 143 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | 66 | | |
74 | 67 | | |
75 | 68 | | |
| |||
165 | 158 | | |
166 | 159 | | |
167 | 160 | | |
168 | | - | |
| 161 | + | |
169 | 162 | | |
170 | 163 | | |
171 | 164 | | |
| |||
0 commit comments