Skip to content

Commit 9df06a3

Browse files
committed
Add man page output to nix-channel-index
1 parent 071ab47 commit 9df06a3

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/bin/nix-channel-index.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ async fn update_index(args: &Args) -> Result<()> {
175175
}
176176

177177
#[derive(Debug, Parser)]
178-
#[clap(author, about, version)]
178+
#[clap(author, about, version, name = "nix-channel-index")]
179179
struct Args {
180180
/// Make REQUESTS http requests in parallel
181181
#[clap(short = 'r', long = "requests", default_value = "500")]
@@ -200,12 +200,28 @@ struct Args {
200200
/// Show a stack trace in the case of a Nix evaluation error
201201
#[clap(long)]
202202
show_trace: bool,
203+
204+
/// Generate man page, then exit.
205+
#[clap(long, hide = true)]
206+
mangen: bool,
203207
}
204208

205209
#[tokio::main]
206210
async fn main() {
207211
let args = Args::parse();
208212

213+
if args.mangen {
214+
use clap::CommandFactory;
215+
let man = clap_mangen::Man::new(Args::command());
216+
217+
if let Err(err) = man.render(&mut std::io::stdout()) {
218+
eprintln!("error: {}", err);
219+
process::exit(2)
220+
} else {
221+
return;
222+
}
223+
}
224+
209225
if let Err(e) = update_index(&args).await {
210226
eprintln!("error: {:?}", e);
211227
process::exit(2);

0 commit comments

Comments
 (0)