licensebat-cli 0.23.0

CLI tool to manage dependencies' license validation
Documentation
use std::str::FromStr;
use structopt::StructOpt;

/// Struct representing the args of the CLI.
#[derive(Debug, StructOpt, Clone)]
#[structopt(
    name = "๐Ÿฆ‡  Licensebat",
    author("๐Ÿ’ป  Roberto Huertas <roberto.huertas@outlook.com>"),
    long_about = "๐Ÿงฐ  Utility to help you check that your project's dependencies comply with your license policy.\n๐Ÿฆ€  Humbly written with Rust. ๐Ÿงก\n  
    โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„
    โ–ˆโ–ˆโ–‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–ˆโ–ˆโ–€โ–„โ–€โ–ˆโ–‘โ–„โ–„โ–ˆโ–‘โ–„โ–„โ–€โ–ˆโ–‘โ–„โ–„โ–ˆโ–‘โ–„โ–„โ–ˆโ–‘โ–„โ–„โ–€โ–ˆโ–‘โ–„โ–„โ–€โ–ˆโ–„โ–‘โ–„
    โ–ˆโ–ˆโ–‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–„โ–ˆโ–‘โ–ˆโ–€โ–ˆโ–‘โ–„โ–„โ–ˆโ–‘โ–ˆโ–ˆโ–‘โ–ˆโ–„โ–„โ–€โ–ˆโ–‘โ–„โ–„โ–ˆโ–‘โ–„โ–„โ–€โ–ˆโ–‘โ–€โ–€โ–‘โ–ˆโ–ˆโ–‘โ–ˆ
    โ–ˆโ–ˆโ–‘โ–€โ–€โ–‘โ–ˆโ–„โ–„โ–„โ–ˆโ–ˆโ–„โ–ˆโ–ˆโ–„โ–„โ–„โ–ˆโ–„โ–ˆโ–ˆโ–„โ–ˆโ–„โ–„โ–„โ–ˆโ–„โ–„โ–„โ–ˆโ–„โ–„โ–„โ–„โ–ˆโ–„โ–ˆโ–ˆโ–„โ–ˆโ–ˆโ–„โ–ˆ
    โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€                                       
"
)]
pub struct Cli {
    /// Path to the file containing the dependencies of the project.
    /// i.e. package-lock.json for npm projects, yarn.lock for yarn projects, etc.
    #[structopt(short, long)]
    pub dependency_file: String,
    /// Path to the .licrc file
    #[structopt(short, long, default_value = ".licrc")]
    pub licrc_file: String,
    /// Output format (json | markdown). Defaults to json.
    #[structopt(short = "f", long, default_value = "json")]
    pub output_format: OutputFormat,
}

/// Format of the CLIs output
#[derive(Debug, Clone)]
pub enum OutputFormat {
    /// Json format
    Json,
    /// Markdown format
    Markdown,
}

impl FromStr for OutputFormat {
    type Err = &'static str;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "markdown" | "md" => Ok(Self::Markdown),
            _ => Ok(Self::Json),
        }
    }
}