Rename commands

This commit is contained in:
Andrey Golovizin 2021-06-29 23:05:11 +02:00
parent cca44441b5
commit 6fdf002608

View file

@ -16,13 +16,13 @@ struct Opts {
}
#[derive(Clap, Debug)]
struct ListOpts {
struct EndpointsOpts {
#[clap(short, long)]
json: bool,
}
#[derive(Clap, Debug)]
struct GetConfigOpts {
struct ConfigOpts {
location: String,
username: String,
token: String,
@ -30,8 +30,8 @@ struct GetConfigOpts {
#[derive(Clap, Debug)]
enum Command {
List(ListOpts),
GetConfig(GetConfigOpts),
Endpoints(EndpointsOpts),
Config(ConfigOpts),
}
#[derive(Serialize, Deserialize, Debug)]
@ -77,13 +77,13 @@ fn main() -> Result<(), anyhow::Error> {
env_logger::init();
let opts = Opts::parse();
match &opts.command {
Command::List(list_opts) => list(&list_opts)?,
Command::GetConfig(get_config_opts) => get_config(&get_config_opts)?,
Command::Endpoints(list_opts) => list(&list_opts)?,
Command::Config(get_config_opts) => get_config(&get_config_opts)?,
}
Ok(())
}
fn list(opts: &ListOpts) -> Result<(), anyhow::Error> {
fn list(opts: &EndpointsOpts) -> Result<(), anyhow::Error> {
let locations: Locations = get_locations()?;
if opts.json {
println!("{}", serde_json::to_string(&locations)?);
@ -108,7 +108,7 @@ fn get_locations() -> Result<Locations, anyhow::Error> {
Ok(locations)
}
fn get_config(opts: &GetConfigOpts) -> Result<(), anyhow::Error> {
fn get_config(opts: &ConfigOpts) -> Result<(), anyhow::Error> {
let locations = get_locations()?;
let location = locations
.locations