use anyhow::bail;
use clap::{Parser, Subcommand};
use chrono::Datelike;
use lazy_static::lazy_static;
use std::path::Path;
use crate::cli::compare::CompareSettings;
use crate::cli::merge::MergeSettings;
lazy_static! {
pub static ref FULL_VERSION: String = format!("{}-{}", env!("CARGO_PKG_VERSION"), env!("VERGEN_GIT_DESCRIBE"));
pub static ref AFTER_HELP: String = format!("Copyright (C) 2004-{} Pacific Biosciences of California, Inc.
This program comes with ABSOLUTELY NO WARRANTY; it is intended for
Research Use Only and not for use in diagnostic procedures.", chrono::Utc::now().year());
}
#[derive(Parser)]
#[clap(author,
version = &**FULL_VERSION,
about,
after_help = &**AFTER_HELP)]
#[command(propagate_version = true)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands
}
#[derive(Subcommand)]
pub enum Commands {
Compare(Box<CompareSettings>),
Merge(Box<MergeSettings>)
}
pub fn get_cli() -> Cli {
Cli::parse()
}
pub fn check_required_filename(filename: &Path, label: &str) -> anyhow::Result<()> {
if !filename.exists() {
bail!("{} does not exist: \"{}\"", label, filename.display());
}
Ok(())
}
pub fn check_optional_filename(opt_filename: Option<&Path>, label: &str) -> anyhow::Result<()> {
if let Some(filename) = opt_filename {
if !filename.exists() {
bail!("{} does not exist: \"{}\"", label, filename.display());
}
}
Ok(())
}