use argh::FromArgs;
use component_debug::cli::{GraphFilter, GraphOrientation, ListFilter};
use component_debug::config::RawConfigEntry;
use component_debug::explore::DashNamespaceLayout;
use fuchsia_url::AbsoluteComponentUrl;
use moniker::Moniker;
#[derive(FromArgs, PartialEq, Debug)]
#[argh(
name = "component",
description = "Discover and manage components. Functionally equivalent to `ffx component`."
)]
pub struct ComponentArgs {
#[argh(subcommand)]
pub subcommand: ComponentSubcommand,
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand)]
pub enum ComponentSubcommand {
Capability(CapabilityArgs),
List(ListArgs),
Graph(GraphArgs),
Show(ShowArgs),
Create(CreateArgs),
Destroy(DestroyArgs),
Resolve(ResolveArgs),
Run(RunArgs),
Start(StartArgs),
Stop(StopArgs),
Reload(ReloadArgs),
Doctor(DoctorArgs),
Copy(CopyArgs),
Storage(StorageArgs),
Collection(CollectionArgs),
Explore(ExploreArgs),
Config(ConfigArgs),
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "show", description = "Same as `ffx component show`")]
pub struct ShowArgs {
#[argh(positional)]
pub query: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "create", description = "Same as `ffx component create`")]
pub struct CreateArgs {
#[argh(positional)]
pub moniker: Moniker,
#[argh(positional)]
pub url: AbsoluteComponentUrl,
#[argh(option)]
pub config: Vec<RawConfigEntry>,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "resolve", description = "Same as `ffx component resolve`")]
pub struct ResolveArgs {
#[argh(positional)]
pub query: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "destroy", description = "Same as `ffx component destroy`")]
pub struct DestroyArgs {
#[argh(positional)]
pub query: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "start", description = "Same as `ffx component start`")]
pub struct StartArgs {
#[argh(positional)]
pub query: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "stop", description = "Same as `ffx component stop`")]
pub struct StopArgs {
#[argh(positional)]
pub query: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "reload", description = "Same as `ffx component reload`")]
pub struct ReloadArgs {
#[argh(positional)]
pub query: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "doctor", description = "Same as `ffx component doctor`")]
pub struct DoctorArgs {
#[argh(positional)]
pub query: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "capability", description = "Same as `ffx component capability`")]
pub struct CapabilityArgs {
#[argh(positional)]
pub capability_name: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "list", description = "Same as `ffx component list`")]
pub struct ListArgs {
#[argh(option, long = "only", short = 'o')]
pub filter: Option<ListFilter>,
#[argh(switch, long = "verbose", short = 'v')]
pub verbose: bool,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "graph", description = "Same as `ffx component graph`")]
pub struct GraphArgs {
#[argh(option, long = "only", short = 'o')]
pub filter: Option<GraphFilter>,
#[argh(option, long = "orientation", short = 'r', default = "GraphOrientation::TopToBottom")]
pub orientation: GraphOrientation,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "run", description = "Same as `ffx component run`")]
pub struct RunArgs {
#[argh(positional)]
pub moniker: Moniker,
#[argh(positional)]
pub url: AbsoluteComponentUrl,
#[argh(switch, short = 'r')]
pub recreate: bool,
#[argh(switch)]
pub connect_stdio: bool,
#[argh(option)]
pub config: Vec<RawConfigEntry>,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "copy", description = "Same as `ffx component copy`")]
pub struct CopyArgs {
#[argh(positional)]
pub paths: Vec<String>,
#[argh(switch, short = 'v')]
pub verbose: bool,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "storage", description = "Same as `ffx component storage`")]
pub struct StorageArgs {
#[argh(subcommand)]
pub subcommand: StorageSubcommand,
#[argh(option, default = "String::from(\"/core\")")]
pub provider: String,
#[argh(option, default = "String::from(\"data\")")]
pub capability: String,
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand)]
pub enum StorageSubcommand {
Copy(StorageCopyArgs),
Delete(StorageDeleteArgs),
List(StorageListArgs),
MakeDirectory(StorageMakeDirectoryArgs),
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "list", description = "Same as `ffx component storage list`")]
pub struct StorageListArgs {
#[argh(positional)]
pub path: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(
subcommand,
name = "make-directory",
description = "Same as `ffx component storage make-directory`"
)]
pub struct StorageMakeDirectoryArgs {
#[argh(positional)]
pub path: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "copy", description = "Same as `ffx component storage copy`")]
pub struct StorageCopyArgs {
#[argh(positional)]
pub source_path: String,
#[argh(positional)]
pub destination_path: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "delete", description = "Same as `ffx component storage delete`")]
pub struct StorageDeleteArgs {
#[argh(positional)]
pub path: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "collection", description = "Same as `ffx component collection`")]
pub struct CollectionArgs {
#[argh(subcommand)]
pub subcommand: CollectionSubcommand,
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand)]
pub enum CollectionSubcommand {
List(CollectionListArgs),
Show(CollectionShowArgs),
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "list", description = "Same as `ffx component collection list`")]
pub struct CollectionListArgs {
#[argh(positional)]
pub path: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "show", description = "Same as `ffx component collection show`")]
pub struct CollectionShowArgs {
#[argh(positional)]
pub query: String,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "explore", description = "Same as `ffx component explore`")]
pub struct ExploreArgs {
#[argh(positional)]
pub query: String,
#[argh(option)]
pub tools: Vec<String>,
#[argh(option, short = 'c', long = "command")]
pub command: Option<String>,
#[argh(
option,
short = 'l',
long = "layout",
default = "DashNamespaceLayout::NestAllInstanceDirs"
)]
pub ns_layout: DashNamespaceLayout,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "config", description = "Same as `ffx component config`")]
pub struct ConfigArgs {
#[argh(subcommand)]
pub subcommand: ConfigSubcommand,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand)]
pub enum ConfigSubcommand {
Set(SetArgs),
Unset(UnsetArgs),
List(ConfigListArgs),
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "set", description = "Same as `ffx component config set`")]
pub struct SetArgs {
#[argh(positional)]
pub query: String,
#[argh(positional)]
pub key_values: Vec<String>,
#[argh(switch, short = 'r')]
pub reload: bool,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "unset", description = "Same as `ffx component config unset`")]
pub struct UnsetArgs {
#[argh(positional)]
pub query: Option<String>,
#[argh(switch, short = 'r')]
pub reload: bool,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "list", description = "Same as `ffx component config list`")]
pub struct ConfigListArgs {
#[argh(positional)]
pub query: String,
}