seaplane_cli/cli/cmds/
license.rs1use clap::{ArgMatches, Command};
2
3use crate::{cli::CliCommand, error::Result, Ctx};
4
5static THIRD_PARTY_LICENSES: &str =
6 include_str!(concat!(env!("OUT_DIR"), "/third_party_licenses.md"));
7
8static SELF_LICENSE: &str = include_str!(concat!(env!("OUT_DIR"), "/LICENSE"));
14
15#[derive(Copy, Clone, Debug)]
16pub struct SeaplaneLicense;
17
18impl SeaplaneLicense {
19 pub fn command() -> Command {
20 Command::new("license")
21 .about("Print license information")
22 .arg(
23 arg!(--("third-party"))
24 .help("Display a list of third party libraries and their licenses"),
25 )
26 }
27}
28
29impl CliCommand for SeaplaneLicense {
30 fn run(&self, ctx: &mut Ctx) -> Result<()> {
31 if ctx.args.third_party {
32 println!("{THIRD_PARTY_LICENSES}");
33 } else {
34 println!("{SELF_LICENSE}");
35 }
36
37 Ok(())
38 }
39
40 fn update_ctx(&self, matches: &ArgMatches, ctx: &mut Ctx) -> Result<()> {
41 ctx.args.third_party = matches.get_flag("third-party");
42 Ok(())
43 }
44}