use anyhow::Result;
use clap::{Arg, ArgMatches, Command};
use log::debug;
const ARG_DIR: &str = "dir";
const CMD_MAN: &str = "man";
pub enum Cmd<'a> {
GenerateAll(&'a str),
}
pub fn matches(m: &ArgMatches) -> Result<Option<Cmd>> {
if let Some(m) = m.subcommand_matches(CMD_MAN) {
let dir = m.get_one::<String>(ARG_DIR).map(String::as_str).unwrap();
debug!("directory: {}", dir);
return Ok(Some(Cmd::GenerateAll(dir)));
};
Ok(None)
}
pub fn subcmd() -> Command {
Command::new(CMD_MAN)
.about("Generates all man pages to the specified directory.")
.arg(
Arg::new(ARG_DIR)
.help("Directory where to generate man files")
.long_help("Represents the directory where all man files of all commands and subcommands should be generated in.")
.required(true),
)
}