1use argh::FromArgs;
6use fidl_fuchsia_dash as fdash;
7
8#[derive(FromArgs, PartialEq, Debug)]
9#[argh(name = "package", description = "Interact with the packaging system.")]
10pub struct PackageArgs {
11 #[argh(subcommand)]
12 pub subcommand: PackageSubcommand,
13}
14
15#[derive(FromArgs, PartialEq, Debug)]
16#[argh(subcommand)]
17pub enum PackageSubcommand {
18 Explore(ExploreArgs),
19}
20
21#[derive(FromArgs, Debug, PartialEq)]
22#[argh(subcommand, name = "explore", description = "Same as `ffx target-package explore`")]
23pub struct ExploreArgs {
24 #[argh(positional)]
25 pub url: String,
28
29 #[argh(option, long = "subpackage")]
30 pub subpackages: Vec<String>,
34
35 #[argh(option)]
36 pub tools: Vec<String>,
41
42 #[argh(option, short = 'c', long = "command")]
43 pub command: Option<String>,
46
47 #[argh(option, default = "fdash::FuchsiaPkgResolver::Full", from_str_fn(parse_resolver))]
48 pub fuchsia_pkg_resolver: fdash::FuchsiaPkgResolver,
51}
52
53fn parse_resolver(flag: &str) -> Result<fdash::FuchsiaPkgResolver, String> {
54 Ok(match flag {
55 "base" => fdash::FuchsiaPkgResolver::Base,
56 "full" => fdash::FuchsiaPkgResolver::Full,
57 _ => return Err("supported fuchsia-pkg resolvers are: 'base' and 'full'".into()),
58 })
59}