Skip to content

Commit 8f3d345

Browse files
committed
Add man page output to nix-index
1 parent 9df06a3 commit 8f3d345

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/bin/nix-index.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn cache_dir() -> &'static OsStr {
132132

133133
/// Builds an index for nix-locate
134134
#[derive(Debug, Parser)]
135-
#[clap(author, about, version)]
135+
#[clap(author, about, version, name = "nix-index")]
136136
struct Args {
137137
/// Make REQUESTS http requests in parallel
138138
#[clap(short = 'r', long = "requests", default_value = "100")]
@@ -168,12 +168,28 @@ struct Args {
168168
/// Note: does not check if the cached data is up to date! Use only for development.
169169
#[clap(long)]
170170
path_cache: bool,
171+
172+
/// Generate man page, then exit
173+
#[clap(long, hide = true)]
174+
mangen: bool,
171175
}
172176

173177
#[tokio::main]
174178
async fn main() {
175179
let args = Args::parse();
176180

181+
if args.mangen {
182+
use clap::CommandFactory;
183+
let man = clap_mangen::Man::new(Args::command());
184+
185+
if let Err(err) = man.render(&mut std::io::stdout()) {
186+
eprintln!("error: {}", err);
187+
process::exit(2)
188+
} else {
189+
return;
190+
}
191+
}
192+
177193
if let Err(e) = update_index(&args).await {
178194
eprintln!("error: {:?}", e);
179195
process::exit(2);

0 commit comments

Comments
 (0)