1use super::subcommands::composite::args::CompositeCommand;
6use super::subcommands::disable::args::DisableCommand;
7use super::subcommands::doctor::args::DoctorCommand;
8use super::subcommands::dump::args::DumpCommand;
9use super::subcommands::enable::args::EnableCommand;
10use super::subcommands::host::args::HostCommand;
11use super::subcommands::list::args::ListCommand;
12use super::subcommands::list_composite_node_specs::args::ListCompositeNodeSpecsCommand;
13use super::subcommands::list_composites::args::ListCompositesCommand;
14use super::subcommands::list_devices::args::ListDevicesCommand;
15use super::subcommands::list_hosts::args::ListHostsCommand;
16use super::subcommands::node::args::NodeCommand;
17use super::subcommands::register::args::RegisterCommand;
18use super::subcommands::restart::args::RestartCommand;
19use super::subcommands::show::args::ShowCommand;
20use super::subcommands::test_node::args::TestNodeCommand;
21use argh::{ArgsInfo, FromArgs};
22
23#[derive(Debug, PartialEq)]
24pub struct Boxed<T>(pub Box<T>);
25
26impl<T: argh::FromArgs> argh::FromArgs for Boxed<T> {
27 fn from_args(command_name: &[&str], args: &[&str]) -> Result<Self, argh::EarlyExit> {
28 T::from_args(command_name, args).map(|t| Boxed(Box::new(t)))
29 }
30 fn redact_arg_values(
31 command_name: &[&str],
32 args: &[&str],
33 ) -> Result<Vec<String>, argh::EarlyExit> {
34 T::redact_arg_values(command_name, args)
35 }
36}
37
38impl<T: argh::SubCommand> argh::SubCommand for Boxed<T> {
39 const COMMAND: &'static argh::CommandInfo = T::COMMAND;
40}
41
42impl<T: argh::ArgsInfo> argh::ArgsInfo for Boxed<T> {
43 fn get_args_info() -> argh::CommandInfoWithArgs {
44 T::get_args_info()
45 }
46}
47
48#[cfg(not(target_os = "fuchsia"))]
49use static_checks_lib::args::StaticChecksCommand;
50
51pub type BoxedDisableCommand = Boxed<DisableCommand>;
52pub type BoxedEnableCommand = Boxed<EnableCommand>;
53pub type BoxedDoctorCommand = Boxed<DoctorCommand>;
54pub type BoxedDumpCommand = Boxed<DumpCommand>;
55pub type BoxedListCommand = Boxed<ListCommand>;
56pub type BoxedListCompositesCommand = Boxed<ListCompositesCommand>;
57pub type BoxedListDevicesCommand = Boxed<ListDevicesCommand>;
58pub type BoxedListHostsCommand = Boxed<ListHostsCommand>;
59pub type BoxedListCompositeNodeSpecsCommand = Boxed<ListCompositeNodeSpecsCommand>;
60pub type BoxedRegisterCommand = Boxed<RegisterCommand>;
61pub type BoxedRestartCommand = Boxed<RestartCommand>;
62pub type BoxedShowCommand = Boxed<ShowCommand>;
63pub type BoxedTestNodeCommand = Boxed<TestNodeCommand>;
64pub type BoxedNodeCommand = Boxed<NodeCommand>;
65pub type BoxedHostCommand = Boxed<HostCommand>;
66pub type BoxedCompositeCommand = Boxed<CompositeCommand>;
67#[cfg(not(target_os = "fuchsia"))]
68pub type BoxedStaticChecksCommand = Boxed<StaticChecksCommand>;
69
70#[derive(ArgsInfo, FromArgs, Debug, PartialEq)]
71#[argh(name = "driver", description = "Support driver development workflows")]
72pub struct DriverCommand {
73 #[argh(switch, short = 's', long = "select")]
75 pub select: bool,
76
77 #[argh(subcommand)]
78 pub subcommand: DriverSubCommand,
79}
80
81#[cfg(target_os = "fuchsia")]
82#[derive(ArgsInfo, FromArgs, Debug, PartialEq)]
83#[argh(subcommand)]
84pub enum DriverSubCommand {
85 Disable(BoxedDisableCommand),
86 Enable(BoxedEnableCommand),
87 Doctor(BoxedDoctorCommand),
88 Dump(BoxedDumpCommand),
89 List(BoxedListCommand),
90 ListComposites(BoxedListCompositesCommand),
91 ListDevices(BoxedListDevicesCommand),
92 ListHosts(BoxedListHostsCommand),
93 ListCompositeNodeSpecs(BoxedListCompositeNodeSpecsCommand),
94 Register(BoxedRegisterCommand),
95 Restart(BoxedRestartCommand),
96 Show(BoxedShowCommand),
97 TestNode(BoxedTestNodeCommand),
98 Node(BoxedNodeCommand),
100 Host(BoxedHostCommand),
101 Composite(BoxedCompositeCommand),
102}
103
104#[cfg(not(target_os = "fuchsia"))]
105#[derive(ArgsInfo, FromArgs, Debug, PartialEq)]
106#[argh(subcommand)]
107pub enum DriverSubCommand {
108 Disable(BoxedDisableCommand),
109 Enable(BoxedEnableCommand),
110 Doctor(BoxedDoctorCommand),
111 Dump(BoxedDumpCommand),
112 List(BoxedListCommand),
113 ListComposites(BoxedListCompositesCommand),
114 ListDevices(BoxedListDevicesCommand),
115 ListHosts(BoxedListHostsCommand),
116 ListCompositeNodeSpecs(BoxedListCompositeNodeSpecsCommand),
117 Register(BoxedRegisterCommand),
118 Restart(BoxedRestartCommand),
119 StaticChecks(BoxedStaticChecksCommand),
120 Show(BoxedShowCommand),
121 TestNode(BoxedTestNodeCommand),
122 Node(BoxedNodeCommand),
124 Host(BoxedHostCommand),
125 Composite(BoxedCompositeCommand),
126}