From 23aecbf14f4546629f46c68b98f66df4fc380690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Lehmann?= Date: Sat, 3 Feb 2024 16:28:14 +0100 Subject: [PATCH] automatically update the markdown command line help --- Cargo.lock | 23 ++++++++++++++--- Cargo.toml | 1 + build.rs | 13 ++++++++-- docs/CommandLineHelp.md | 5 ++-- docs/yage.1 | 55 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 docs/yage.1 diff --git a/Cargo.lock b/Cargo.lock index 081a5d3..6c57d1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -281,6 +281,16 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +[[package]] +name = "clap_mangen" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e35a078f3aae828c9b7ad58e1631dab87e9dac40da19418f2219bbf3198aa5c" +dependencies = [ + "clap", + "roff", +] + [[package]] name = "colorchoice" version = "1.0.0" @@ -912,6 +922,12 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "roff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316" + [[package]] name = "rust-embed" version = "6.8.1" @@ -1230,7 +1246,7 @@ dependencies = [ [[package]] name = "treediff" version = "4.0.2" -source = "git+https://github.com/glehmann/treediff-rs.git?branch=serde-yaml-09#f42592e30732737d526b2560f8d6b7bec380c82d" +source = "git+https://github.com/glehmann/treediff-rs.git?branch=serde-yaml-09#3177d4a6fc8226fa3fdfef656f934db0b75db541" dependencies = [ "serde_yaml", ] @@ -1490,9 +1506,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.36" +version = "0.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "818ce546a11a9986bc24f93d0cdf38a8a1a400f1473ea8c82e59f6e0ffab9249" +checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5" dependencies = [ "memchr", ] @@ -1518,6 +1534,7 @@ dependencies = [ "clap-markdown", "clap-verbosity-flag", "clap_complete", + "clap_mangen", "log", "ocli", "serde_yaml", diff --git a/Cargo.toml b/Cargo.toml index ce43f49..340a290 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,7 @@ clap = { version = "4.4.18", features = ["derive", "env", "wrap_help"] } clap-markdown = "0.1.3" clap-verbosity-flag = "2.1.2" clap_mangen = "0.2.18" +clap_complete = "4.4.10" [profile.release] strip = "symbols" diff --git a/build.rs b/build.rs index a797daf..88a670a 100644 --- a/build.rs +++ b/build.rs @@ -1,14 +1,16 @@ +use std::{fs, io::Write}; + include!("src/cli.rs"); fn main() -> std::io::Result<()> { generate_man::()?; + generate_markdown::()?; Ok(()) } fn generate_man() -> std::io::Result<()> { let command = C::command(); - let out_dir = - std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or(std::io::ErrorKind::NotFound)?); + let out_dir: PathBuf = "docs".into(); let name = command.get_name(); let name = if name == "yage" { "yage.1".to_owned() @@ -22,3 +24,10 @@ fn generate_man() -> std::io::Result<()> { std::fs::write(fname, buffer)?; Ok(()) } + +fn generate_markdown() -> std::io::Result<()> { + let md = clap_markdown::help_markdown::(); + let mut f = fs::File::create("docs/CommandLineHelp.md")?; + write!(f, "{md}")?; + Ok(()) +} diff --git a/docs/CommandLineHelp.md b/docs/CommandLineHelp.md index dc9200f..d61ca15 100644 --- a/docs/CommandLineHelp.md +++ b/docs/CommandLineHelp.md @@ -14,9 +14,9 @@ This document contains the help content for the `yage` command-line program. ## `yage` -A simple tool to manage encrypted secrets in YAML files. +A simple tool to manage encrypted secrets in YAML files with age encryption -**Usage:** `yage [OPTIONS] [COMMAND]` +**Usage:** `yage [OPTIONS] ` ###### **Subcommands:** @@ -194,4 +194,3 @@ The input key and output public key are in the age format, which is compatible w This document was generated automatically by clap-markdown. - diff --git a/docs/yage.1 b/docs/yage.1 new file mode 100644 index 0000000..366256f --- /dev/null +++ b/docs/yage.1 @@ -0,0 +1,55 @@ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.TH yage 1 "yage 0.1.0" +.SH NAME +yage \- A simple tool to manage encrypted secrets in YAML files with age encryption +.SH SYNOPSIS +\fByage\fR [\fB\-\-completion\fR] [\fB\-v\fR|\fB\-\-verbose\fR]... [\fB\-q\fR|\fB\-\-quiet\fR]... [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] <\fIsubcommands\fR> +.SH DESCRIPTION +A simple tool to manage encrypted secrets in YAML files with age encryption +.SH OPTIONS +.TP +\fB\-\-completion\fR=\fISHELL\fR +Generate the completion code for this shell +.br + +.br +[\fIpossible values: \fRbash, elvish, fish, powershell, zsh] +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Increase logging verbosity +.TP +\fB\-q\fR, \fB\-\-quiet\fR +Decrease logging verbosity +.TP +\fB\-h\fR, \fB\-\-help\fR +Print help +.TP +\fB\-V\fR, \fB\-\-version\fR +Print version +.SH SUBCOMMANDS +.TP +yage\-decrypt(1) +Decrypt the values in a YAML file +.TP +yage\-edit(1) +Edit an encrypted YAML file +.TP +yage\-encrypt(1) +Encrypt the values in a YAML file +.TP +yage\-env(1) +Execute a command with the environment from the encrypted YAML file +.TP +yage\-keygen(1) +Generate a new age key +.TP +yage\-pubkey(1) +Convert private age keys to their public key +.TP +yage\-help(1) +Print this message or the help of the given subcommand(s) +.SH VERSION +v0.1.0 +.SH AUTHORS +Gaƫtan Lehmann