mod account;
mod assets;
mod ble;
mod busy;
mod input;
mod mirror;
mod settings;
mod smart_home;
mod storage;
mod streaming;
mod system;
mod time;
mod updater;
mod wifi;
use clap::Subcommand;
use crate::cli::Context;
use crate::error::Result;
use crate::types::screen_arg::ScreenArg;
#[derive(Debug, Subcommand)]
pub enum Command {
Api {
#[command(subcommand)]
command: ApiCommand,
},
Mirror {
#[arg(long, value_enum, default_value_t = ScreenArg::Front)]
screen: ScreenArg,
#[arg(long)]
no_screen_raster: bool,
},
}
#[derive(Debug, Subcommand)]
pub enum ApiCommand {
Account {
#[command(subcommand)]
command: account::AccountCommand,
},
Assets {
#[command(subcommand)]
command: assets::AssetsCommand,
},
Ble {
#[command(subcommand)]
command: ble::BleCommand,
},
Busy {
#[command(subcommand)]
command: busy::BusyCommand,
},
Input {
#[command(subcommand)]
command: input::InputCommand,
},
Settings {
#[command(subcommand)]
command: settings::SettingsCommand,
},
#[command(name = "smart-home")]
SmartHome {
#[command(subcommand)]
command: smart_home::SmartHomeCommand,
},
Storage {
#[command(subcommand)]
command: storage::StorageCommand,
},
Streaming {
#[command(subcommand)]
command: streaming::StreamingCommand,
},
System {
#[command(subcommand)]
command: system::SystemCommand,
},
Time {
#[command(subcommand)]
command: time::TimeCommand,
},
Updater {
#[command(subcommand)]
command: updater::UpdaterCommand,
},
Wifi {
#[command(subcommand)]
command: wifi::WifiCommand,
},
}
impl Command {
pub async fn run(self, context: &Context) -> Result<()> {
match self {
Command::Api { command } => command.run(context).await,
Command::Mirror {
screen,
no_screen_raster,
} => mirror::run(context, screen, no_screen_raster).await,
}
}
}
impl ApiCommand {
pub async fn run(self, context: &Context) -> Result<()> {
match self {
ApiCommand::Account { command } => command.run(context).await,
ApiCommand::Assets { command } => command.run(context).await,
ApiCommand::Ble { command } => command.run(context).await,
ApiCommand::Busy { command } => command.run(context).await,
ApiCommand::Input { command } => command.run(context).await,
ApiCommand::Settings { command } => command.run(context).await,
ApiCommand::SmartHome { command } => command.run(context).await,
ApiCommand::Storage { command } => command.run(context).await,
ApiCommand::Streaming { command } => command.run(context).await,
ApiCommand::System { command } => command.run(context).await,
ApiCommand::Time { command } => command.run(context).await,
ApiCommand::Updater { command } => command.run(context).await,
ApiCommand::Wifi { command } => command.run(context).await,
}
}
}