Skip to content

Commit 7fa2dbf

Browse files
authored
mosskeys-cli: brand-styled, wrapped --help (enable clap wrap_help); v0.2.3 (#10)
1 parent fc0812d commit 7fa2dbf

3 files changed

Lines changed: 77 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 42 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resolver = "3"
33
members = ["crates/mosskeys-core", "crates/mosskeys-cli"]
44

55
[workspace.package]
6-
version = "0.2.2"
6+
version = "0.2.3"
77
edition = "2024"
88
rust-version = "1.85"
99
license = "MIT OR Apache-2.0"
@@ -31,7 +31,7 @@ base64 = "0.22"
3131
thiserror = "2"
3232
toml = "0.8"
3333
directories = "5"
34-
clap = { version = "4", features = ["derive", "env"] }
34+
clap = { version = "4", features = ["derive", "env", "wrap_help"] }
3535

3636
# Build against the sibling metamorphic-crypto working tree. metamorphic-log
3737
# declares `metamorphic-crypto = "0.10.5"` (caret) from crates.io; this patch

crates/mosskeys-cli/src/cli.rs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,45 @@
22
33
use std::path::PathBuf;
44

5+
use clap::builder::styling::{Color, RgbColor, Style, Styles};
56
use clap::{Args, Parser, Subcommand};
67
use mosskeys_core::{Client, Config};
78

89
use crate::output::Reporter;
910

10-
/// MossKeys — publish public key material and sign checkpoints locally (BYOK).
11+
/// Brand-aligned help styles, mirroring the terminal theme (see `theme.rs`):
12+
/// section headers and usage in emerald, commands/flags (the tokens you type)
13+
/// in bright emerald, and argument placeholders in cyber cyan. clap only paints
14+
/// these on a TTY and honours `NO_COLOR`, so pipes and CI stay plain.
15+
const fn help_styles() -> Styles {
16+
// Sampled from the web design system's dark-mode shades, identical to the
17+
// palette in `theme.rs`.
18+
const BRAND: Color = Color::Rgb(RgbColor(52, 211, 153)); // brand-400 / emerald
19+
const BRAND_LIGHT: Color = Color::Rgb(RgbColor(110, 231, 183)); // emerald-300
20+
const CYBER: Color = Color::Rgb(RgbColor(34, 211, 238)); // cyber-400
21+
const DANGER: Color = Color::Rgb(RgbColor(252, 165, 165)); // red-300
22+
23+
Styles::styled()
24+
.header(Style::new().bold().underline().fg_color(Some(BRAND)))
25+
.usage(Style::new().bold().underline().fg_color(Some(BRAND)))
26+
.literal(Style::new().bold().fg_color(Some(BRAND_LIGHT)))
27+
.placeholder(Style::new().fg_color(Some(CYBER)))
28+
.valid(Style::new().fg_color(Some(BRAND_LIGHT)))
29+
.invalid(Style::new().bold().fg_color(Some(DANGER)))
30+
.error(Style::new().bold().fg_color(Some(DANGER)))
31+
}
32+
33+
/// mosskeys — publish public key material and sign checkpoints locally (BYOK).
1134
#[derive(Debug, Parser)]
12-
#[command(name = "mosskeys", version, about, long_about = None)]
35+
#[command(
36+
name = "mosskeys",
37+
version,
38+
about,
39+
long_about = None,
40+
next_line_help = true,
41+
max_term_width = 100,
42+
styles = help_styles()
43+
)]
1344
pub struct Cli {
1445
#[command(flatten)]
1546
pub global: GlobalArgs,

0 commit comments

Comments
 (0)