Add shell completion and manpage generation (#233)

This commit is contained in:
Marcin Puc
2022-11-26 20:42:35 +01:00
committed by GitHub
parent 37b900c56a
commit f6ec6c76db
5 changed files with 51 additions and 80 deletions

View File

@@ -4,6 +4,7 @@ use std::env;
use std::io;
use std::process::exit;
use clap::CommandFactory;
use clap::{crate_version, Parser};
use color_eyre::eyre::Context;
use color_eyre::eyre::{eyre, Result};
@@ -42,6 +43,18 @@ fn run() -> Result<()> {
let opt = CommandLineArgs::parse();
if let Some(shell) = opt.gen_completion {
let cmd = &mut CommandLineArgs::command();
clap_complete::generate(shell, cmd, clap::crate_name!(), &mut std::io::stdout());
return Ok(());
}
if opt.gen_manpage {
let man = clap_mangen::Man::new(CommandLineArgs::command());
man.render(&mut std::io::stdout())?;
return Ok(());
}
install_tracing(&opt.tracing_filter_directives())?;
for env in opt.env_variables() {