use clap::{ArgMatches, Command};
use crate::{cli::CliCommand, error::Result, Ctx};
static THIRD_PARTY_LICENSES: &str =
include_str!(concat!(env!("OUT_DIR"), "/third_party_licenses.md"));
static SELF_LICENSE: &str = include_str!(concat!(env!("OUT_DIR"), "/LICENSE"));
#[derive(Copy, Clone, Debug)]
pub struct SeaplaneLicense;
impl SeaplaneLicense {
pub fn command() -> Command {
Command::new("license")
.about("Print license information")
.arg(
arg!(--("third-party"))
.help("Display a list of third party libraries and their licenses"),
)
}
}
impl CliCommand for SeaplaneLicense {
fn run(&self, ctx: &mut Ctx) -> Result<()> {
if ctx.args.third_party {
println!("{THIRD_PARTY_LICENSES}");
} else {
println!("{SELF_LICENSE}");
}
Ok(())
}
fn update_ctx(&self, matches: &ArgMatches, ctx: &mut Ctx) -> Result<()> {
ctx.args.third_party = matches.get_flag("third-party");
Ok(())
}
}