use crate::{OnceCommand, command::antennas::CalculateAntennaLengths, error::CliError};
use clap::{Args, Subcommand};
use rfham_antennas::AntennaForm;
use rfham_core::countries::CountryCode;
use rfham_itu::allocations::FrequencyAllocation;
use std::process::ExitCode;
#[derive(Debug, Subcommand)]
pub enum AntennaCommands {
Length(CmdAntennaLength),
}
#[derive(Debug, Args)]
#[command(arg_required_else_help = true)]
pub struct CmdAntennaLength {
#[arg(short = 'b', long, requires = "country")]
band: FrequencyAllocation,
#[arg(short = 'c', long, env = "RFHAM_COUNTRY")]
country: CountryCode,
#[arg(short = 'k', long, default_value_t = AntennaForm::Dipole)]
kind: AntennaForm,
}
impl OnceCommand for AntennaCommands {
type Output = ExitCode;
type Error = CliError;
fn execute(self) -> Result<Self::Output, Self::Error> {
match self {
Self::Length(cmd_antenna_length) => cmd_antenna_length.execute(),
}
}
}
impl OnceCommand for CmdAntennaLength {
type Output = ExitCode;
type Error = CliError;
fn execute(self) -> Result<Self::Output, Self::Error> {
CalculateAntennaLengths::new(self.country, self.band).execute()
}
}