1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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(())
}
}