feat(cli): add docgen cmd and jsonschema just target

This commit adds a docgen command to generate markdown documentation
files of all of the CLI commands, and a justfile target to generate
JSONSchema files.
This commit is contained in:
LGUG2Z committed 2025-09-26 12:49:23 -07:00
1 parent 486aecda4c
commit 7bb0aaac48
2 files changed
+41 -2

No files matched your search

+8
View File
@@ -42,6 +42,14 @@ trace target $RUST_LOG="trace":
deadlock $RUST_LOG="trace":
cargo +stable run --bin komorebi --locked --no-default-features --features deadlock_detection
docgen:
cargo run --package komorebic -- docgen
find docs/cli -type f -exec sed -i.bak 's/Usage: /Usage: komorebic /g' {} \; && find docs/cli -name "*.bak" -delete
jsonschema:
cargo run --package komorebic -- static-config-schema > schema.json
cargo run --package komorebic -- application-specific-configuration-schema > schema.asc.json
depgen:
cargo deny check
cargo deny list --format json | jq 'del(.unlicensed)' > dependencies.json
+33 -2
View File
@@ -1,6 +1,7 @@
#![warn(clippy::all)]
use chrono::Utc;
use clap::CommandFactory;
use clap::Parser;
use clap::ValueEnum;
use color_eyre::eyre;
@@ -610,8 +611,8 @@ struct Opts {
#[derive(Parser)]
enum SubCommand {
// #[clap(hide = true)]
// Docgen,
#[clap(hide = true)]
Docgen,
// /// Gather example configurations for a new-user quickstart
// Quickstart,
/// Start komorebi.exe as a background process
@@ -1146,6 +1147,36 @@ fn main() -> eyre::Result<()> {
let opts: Opts = Opts::parse();
match opts.subcmd {
SubCommand::Docgen => {
let mut cli = Opts::command();
let subcommands = cli.get_subcommands_mut();
std::fs::create_dir_all("docs/cli")?;
let ignore = [
"docgen",
"alt-focus-hack",
"identify-border-overflow-application",
"load-custom-layout",
"workspace-custom-layout",
"named-workspace-custom-layout",
"workspace-custom-layout-rule",
"named-workspace-custom-layout-rule",
"focus-follows-mouse",
"toggle-focus-follows-mouse",
"format-app-specific-configuration",
];
for cmd in subcommands {
let name = cmd.get_name().to_string();
if !ignore.contains(&name.as_str()) {
let help_text = cmd.render_long_help().to_string();
let outpath = format!("docs/cli/{name}.md");
let markdown = format!("# {name}\n\n```\n{help_text}\n```");
std::fs::write(outpath, markdown)?;
println!(" - cli/{name}.md");
}
}
}
SubCommand::Start(arg) => {
let mut command = &mut Command::new("komorebi");