Reveerse comand namespace

This commit is contained in:
Adrian Woźniak 2021-08-05 10:27:00 +02:00
parent de85a17e66
commit 806e8da4ee
No known key found for this signature in database
GPG Key ID: 0012845A89C7352B

View File

@ -61,14 +61,6 @@ pub enum FanMode {
Automatic, Automatic,
} }
#[derive(Options)]
pub enum Command {
#[options(help = "GPU card fan control")]
Fan(fan::FanCommand),
#[options(help = "Overclock GPU card")]
Voltage(voltage::VoltageCommand),
}
#[derive(Options)] #[derive(Options)]
pub struct Opts { pub struct Opts {
#[options(help = "Help message")] #[options(help = "Help message")]
@ -76,7 +68,7 @@ pub struct Opts {
#[options(help = "Print version")] #[options(help = "Print version")]
version: bool, version: bool,
#[options(command)] #[options(command)]
command: Option<Command>, command: Option<fan::FanCommand>,
} }
fn main() -> std::io::Result<()> { fn main() -> std::io::Result<()> {
@ -100,15 +92,15 @@ fn main() -> std::io::Result<()> {
match opts.command { match opts.command {
None => fan::service::run(config), None => fan::service::run(config),
Some(Command::Fan(fan::FanCommand::Monitor(monitor))) => fan::monitor::run(monitor, config), Some(fan::FanCommand::Monitor(monitor)) => fan::monitor::run(monitor, config),
Some(Command::Fan(fan::FanCommand::Service(_))) => fan::service::run(config), Some(fan::FanCommand::Service(_)) => fan::service::run(config),
Some(Command::Fan(fan::FanCommand::SetAutomatic(switcher))) => { Some(fan::FanCommand::SetAutomatic(switcher)) => {
fan::change_mode::run(switcher, FanMode::Automatic, config) fan::change_mode::run(switcher, FanMode::Automatic, config)
} }
Some(Command::Fan(fan::FanCommand::SetManual(switcher))) => { Some(fan::FanCommand::SetManual(switcher)) => {
fan::change_mode::run(switcher, FanMode::Manual, config) fan::change_mode::run(switcher, FanMode::Manual, config)
} }
Some(Command::Fan(fan::FanCommand::Available(_))) => { Some(fan::FanCommand::Available(_)) => {
println!("Available cards"); println!("Available cards");
utils::controllers(&config, false)? utils::controllers(&config, false)?
.into_iter() .into_iter()
@ -121,8 +113,5 @@ fn main() -> std::io::Result<()> {
}); });
Ok(()) Ok(())
} }
Some(Command::Voltage(voltage::VoltageCommand::Placeholder(_))) => {
unimplemented!()
}
} }
} }