refactor: reuse POST request structs for cli
This commit is contained in:
parent
68b835124f
commit
844583a6b1
|
@ -15,10 +15,10 @@ pub enum VehicleCommand {
|
|||
ChargePortDoorClose,
|
||||
|
||||
/// Set charge limit.
|
||||
SetChargeLimit { percent: u8 },
|
||||
SetChargeLimit(SetChargeLimit),
|
||||
|
||||
/// Set charge amps.
|
||||
SetChargingAmps { charging_amps: i64 },
|
||||
SetChargingAmps(SetChargingAmps),
|
||||
|
||||
/// Set the charge limit to the standard %.
|
||||
ChargeStandard,
|
||||
|
@ -47,17 +47,11 @@ impl VehicleArgs {
|
|||
VehicleCommand::VehicleData => {
|
||||
print_json(api.vehicle_data(&self.id).await);
|
||||
}
|
||||
VehicleCommand::SetChargeLimit { percent } => {
|
||||
print_json(
|
||||
api.set_charge_limit(&self.id, &SetChargeLimit { percent })
|
||||
.await,
|
||||
);
|
||||
VehicleCommand::SetChargeLimit(limit) => {
|
||||
print_json(api.set_charge_limit(&self.id, &limit).await);
|
||||
}
|
||||
VehicleCommand::SetChargingAmps { charging_amps } => {
|
||||
print_json(
|
||||
api.set_charging_amps(&self.id, &SetChargingAmps { charging_amps })
|
||||
.await,
|
||||
);
|
||||
VehicleCommand::SetChargingAmps(charging_amps) => {
|
||||
print_json(api.set_charging_amps(&self.id, &charging_amps).await);
|
||||
}
|
||||
VehicleCommand::ChargeStart => {
|
||||
print_json(api.charge_start(&self.id).await);
|
||||
|
|
|
@ -314,13 +314,15 @@ pub struct Vehicle {
|
|||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[cfg_attr(feature = "cli", derive(clap::Args))]
|
||||
pub struct SetChargingAmps {
|
||||
pub charging_amps: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[cfg_attr(feature = "cli", derive(clap::Args))]
|
||||
pub struct SetChargeLimit {
|
||||
// pub percent: Percentage,
|
||||
// TODO: percent: Percentage,
|
||||
pub percent: u8,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue