Move --machine to main options

This commit is contained in:
Andrey Golovizin 2023-04-15 12:53:55 +02:00
parent 707d55557e
commit 4e62839513

View file

@ -19,6 +19,9 @@ struct Opts {
#[arg(short, long)] #[arg(short, long)]
json: bool, json: bool,
#[arg(short, long)]
machine: Option<PathBuf>,
#[command(subcommand)] #[command(subcommand)]
command: Command, command: Command,
} }
@ -34,9 +37,6 @@ struct ConfigOpts {
#[arg(short = '4', long)] #[arg(short = '4', long)]
no_ipv6: bool, no_ipv6: bool,
#[arg(short, long)]
machine: Option<PathBuf>,
} }
#[derive(Subcommand, Debug)] #[derive(Subcommand, Debug)]
@ -96,7 +96,7 @@ fn list_locations(opts: &Opts) -> Result<(), anyhow::Error> {
Ok(()) Ok(())
} }
fn get_config(_opts: &Opts, config_opts: &ConfigOpts) -> Result<(), anyhow::Error> { fn get_config(opts: &Opts, config_opts: &ConfigOpts) -> Result<(), anyhow::Error> {
let locations = api::get_locations()?; let locations = api::get_locations()?;
let location = locations let location = locations
.locations .locations
@ -104,7 +104,7 @@ fn get_config(_opts: &Opts, config_opts: &ConfigOpts) -> Result<(), anyhow::Erro
.find(|location| location.name == config_opts.location) .find(|location| location.name == config_opts.location)
.ok_or_else(|| anyhow::anyhow!("no such location: {}", config_opts.location))?; .ok_or_else(|| anyhow::anyhow!("no such location: {}", config_opts.location))?;
debug!("location = {:?}", &location); debug!("location = {:?}", &location);
let keys = get_keys(config_opts.machine.as_ref())?; let keys = get_keys(opts.machine.as_ref())?;
debug!("keys = {:?}", &keys); debug!("keys = {:?}", &keys);
let addresses = api::add_ip(&config_opts.username, &config_opts.token, &keys.public_key)?; let addresses = api::add_ip(&config_opts.username, &config_opts.token, &keys.public_key)?;