Cherry.Commands.Config (cherry v0.4.1)

Copy Markdown View Source

Reads and writes cherry.exs, so a site can be configured without an editor.

Usage

mix cherry.config [--source DIR] [--json]
mix cherry.config KEY [--source DIR] [--json]
mix cherry.config KEY VALUE [--source DIR] [--json]

With no arguments it prints the site's resolved configuration. With a key it prints one value. With a key and a value it writes that value to cherry.exs and reloads the site to prove the result is valid — an invalid write is rolled back and reported, so the file is never left broken.

Writable keys are the scalar ones: ["title", "url", "description", "author", "theme", "search", "base_path", "social_image"]. Structured settings like nav: are refused rather than rewritten, because rewriting them would lose the formatting and comments around them; edit those in the file.

Theme token overrides are the exception, addressed with a dotted key:

cherry config tokens                          # every override
cherry config tokens.--color-accent           # one override
cherry config tokens.--color-accent "#7c3aed" # write one

A written token must exist in the active theme's manifest (cherry theme.tokens lists them), so a typo is an error here rather than a silently ignored line in cherry.exs.

Only the value being changed is rewritten — the rest of the file, including comments and layout, is left byte-for-byte alone.

Summary

Functions

The single-sourced doc text, reused as the mix task's @moduledoc.

Functions

doc()

@spec doc() :: String.t()

The single-sourced doc text, reused as the mix task's @moduledoc.