Rename commands
This commit is contained in:
parent
cca44441b5
commit
6fdf002608
1 changed files with 8 additions and 8 deletions
16
src/main.rs
16
src/main.rs
|
|
@ -16,13 +16,13 @@ struct Opts {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clap, Debug)]
|
#[derive(Clap, Debug)]
|
||||||
struct ListOpts {
|
struct EndpointsOpts {
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
json: bool,
|
json: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clap, Debug)]
|
#[derive(Clap, Debug)]
|
||||||
struct GetConfigOpts {
|
struct ConfigOpts {
|
||||||
location: String,
|
location: String,
|
||||||
username: String,
|
username: String,
|
||||||
token: String,
|
token: String,
|
||||||
|
|
@ -30,8 +30,8 @@ struct GetConfigOpts {
|
||||||
|
|
||||||
#[derive(Clap, Debug)]
|
#[derive(Clap, Debug)]
|
||||||
enum Command {
|
enum Command {
|
||||||
List(ListOpts),
|
Endpoints(EndpointsOpts),
|
||||||
GetConfig(GetConfigOpts),
|
Config(ConfigOpts),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
|
@ -77,13 +77,13 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
let opts = Opts::parse();
|
let opts = Opts::parse();
|
||||||
match &opts.command {
|
match &opts.command {
|
||||||
Command::List(list_opts) => list(&list_opts)?,
|
Command::Endpoints(list_opts) => list(&list_opts)?,
|
||||||
Command::GetConfig(get_config_opts) => get_config(&get_config_opts)?,
|
Command::Config(get_config_opts) => get_config(&get_config_opts)?,
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list(opts: &ListOpts) -> Result<(), anyhow::Error> {
|
fn list(opts: &EndpointsOpts) -> Result<(), anyhow::Error> {
|
||||||
let locations: Locations = get_locations()?;
|
let locations: Locations = get_locations()?;
|
||||||
if opts.json {
|
if opts.json {
|
||||||
println!("{}", serde_json::to_string(&locations)?);
|
println!("{}", serde_json::to_string(&locations)?);
|
||||||
|
|
@ -108,7 +108,7 @@ fn get_locations() -> Result<Locations, anyhow::Error> {
|
||||||
Ok(locations)
|
Ok(locations)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_config(opts: &GetConfigOpts) -> Result<(), anyhow::Error> {
|
fn get_config(opts: &ConfigOpts) -> Result<(), anyhow::Error> {
|
||||||
let locations = get_locations()?;
|
let locations = get_locations()?;
|
||||||
let location = locations
|
let location = locations
|
||||||
.locations
|
.locations
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue