You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
846 B

//! Handles arg parsing
use super::*;
use std::fmt;
mod usage;
/// The name of the process that was invoked
#[inline] pub fn prog_name() -> &'static str
{
lazy_static! {
static ref NAME: String = std::env::args().next().unwrap();
}
&NAME[..]
}
/// Print usage
pub fn print_usage()
{
println!(r#"batchtask v{version} - advanced process batching
by {author} with <3 (licensed GPL3+)"#,
version = env!("CARGO_PKG_VERSION"),
author = env!("CARGO_PKG_AUTHORS"));
println!(r#"
Usage: {prog} [OPTIONS]...
Usage: {prog} --help
{opts}
"#,
prog = prog_name(),
//OPTIONS = "OPTIONS".bright_blue().bold(),
opts = usage::sections().map(|x| lazy_format!("{}", x)).join("\n").trim());
}
/// Print usage then exit
#[inline(always)] pub fn usage() -> !
{
print_usage();
std::process::exit(1)
}