Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resolver = "2"
members = [
"argv",
"config",
"config-build",
"derive",
"clap_usage",
"cli",
Expand Down
25 changes: 25 additions & 0 deletions config-build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "usage-config-build"
description = "Generates a usage-config settings registry from a usage spec, at build time"
version = "5.1.0"
edition = "2021"
rust-version = "1.80.0"
homepage = { workspace = true }
documentation = { workspace = true }
repository = { workspace = true }
authors = { workspace = true }
license = { workspace = true }

# Runs in a build script, so its dependencies cost an adopter's *build* and never ship: the KDL
# parser lives here and `usage-config` carries none of it.
[dependencies]
usage-lib = { workspace = true }

# The generated code is compiled and run in the tests, which is the only way to know it is code
# rather than plausible text.
[dev-dependencies]
usage-config = { workspace = true, features = ["toml"] }

[package.metadata.release]
shared-version = true
release = true
20 changes: 20 additions & 0 deletions config-build/examples/gen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! Regenerates the checked-in registry the tests compile.
//!
//! ```sh
//! cargo run -p usage-config-build --example gen > config-build/tests/golden/settings.rs
//! ```
//!
//! An example rather than a build script, because the point of checking the file in is that a
//! human reads the diff: generated code that nobody looks at is where a generator's mistakes live.

const SPEC: &str = "config-build/tests/fixtures/hk.usage.kdl";

fn main() {
match usage_config_build::source(SPEC) {
Ok(source) => print!("{source}"),
Err(err) => {
eprintln!("{SPEC}: {err}");
std::process::exit(1);
}
}
}
Loading