Skip to content

Commit

Permalink
doc: add man pages
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma committed Jan 4, 2025
1 parent 01ca7a1 commit 53ba284
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:
profile: minimal
toolchain: stable
target: x86_64-unknown-linux-gnu
- run: |
mkdir -p target/man
cargo run --features gen-man-pages -- target/man
gzip -9 target/man/*.1
- uses: taiki-e/install-action@v2
with:
tool: cargo-deb
Expand Down
17 changes: 17 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ strip = true
anyhow = { version = "1.0.93", default-features = false, features = ["std", "backtrace"] }
bincode = { version = "1.3.3", default-features = false }
clap = { version = "4.5.21", default-features = false, features = ["std", "color", "help", "usage", "error-context", "suggestions", "derive"] }
clap_mangen = { version = "0.2.24", default-features = false, optional = true }
function_name = { version = "0.3.0", default-features = false }
itertools = { version = "0.13.0", default-features = false, features = ["use_std"] }
log = { version = "0.4.22", default-features = false, features = ["max_level_trace", "release_max_level_info"] }
Expand All @@ -39,6 +40,7 @@ pretty_assertions = { version = "1.4.1", default-features = false, features = ["
[features]
default = []
as-root = [] # for tests only
gen-man-pages = ["dep:clap_mangen"]
nightly = [] # for benchmarks only

[lints.rust]
Expand Down Expand Up @@ -102,3 +104,7 @@ verbose_file_reads = "warn"
[package.metadata.deb]
name = "shh"
depends = "$auto, strace"
assets = [
["target/release/shh", "usr/bin/", "755"],
["target/man/*.1.gz", "usr/share/man/man1/", "644"]
]
16 changes: 16 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
//! Systemd Hardening Helper
#![cfg_attr(all(feature = "nightly", test), feature(test))]
#![cfg_attr(
feature = "gen-man-pages",
expect(dead_code, unused_crate_dependencies, unused_imports)
)]

use std::{
fs::{self, File},
Expand Down Expand Up @@ -32,6 +36,18 @@ fn sd_options(
sd_opts
}

#[cfg(feature = "gen-man-pages")]
fn main() -> anyhow::Result<()> {
use clap::CommandFactory as _;
let cmd = cl::Args::command();
let output = std::env::args_os()
.nth(1)
.ok_or_else(|| anyhow::anyhow!("Missing output dir argument"))?;
clap_mangen::generate_to(cmd, output)?;
Ok(())
}

#[cfg(not(feature = "gen-man-pages"))]
fn main() -> anyhow::Result<()> {
// Init logger
simple_logger::SimpleLogger::new()
Expand Down

0 comments on commit 53ba284

Please sign in to comment.