webview_bundle_cli/commands/
mod.rs1mod bundle;
2pub mod extract;
3pub mod pack;
4
5use crate::options::{cli_options, CliOptions, ColorsArg};
6use crate::VERSION;
7use bpaf::Bpaf;
8use std::ffi::OsString;
9
10#[derive(Debug, Clone, Bpaf)]
11#[bpaf(options, version(VERSION))]
12pub enum CliCommand {
13 #[bpaf(command)]
15 Pack {
16 #[bpaf(external(cli_options), hide_usage)]
17 cli_options: CliOptions,
18
19 #[bpaf(short('o'), long("outfile"), argument("PATH"), optional)]
23 outfile: Option<String>,
24
25 #[bpaf(long("truncate"), switch)]
27 truncate: bool,
28
29 #[bpaf(positional("PATH"))]
31 dir: OsString,
32 },
33
34 #[bpaf(command)]
36 Extract {
37 #[bpaf(external(cli_options), hide_usage)]
38 cli_options: CliOptions,
39
40 #[bpaf(long("dry-run"), switch)]
42 dry_run: bool,
43
44 #[bpaf(short('o'), long("outdir"), argument("PATH"), optional)]
47 outdir: Option<String>,
48
49 #[bpaf(positional("PATH"))]
51 file: OsString,
52 },
53}
54
55impl CliCommand {
56 const fn cli_options(&self) -> Option<&CliOptions> {
57 match self {
58 CliCommand::Pack { cli_options, .. } | CliCommand::Extract { cli_options, .. } => {
59 Some(cli_options)
60 }
61 }
62 }
63
64 pub const fn get_color(&self) -> Option<&ColorsArg> {
65 match self.cli_options() {
66 Some(cli_options) => cli_options.colors.as_ref(),
67 None => None,
68 }
69 }
70}