Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jbtrystram committed Sep 21, 2021
1 parent feda5b4 commit f066677
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
5 changes: 2 additions & 3 deletions src/apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ pub fn delete(config: &Context, app: AppId, ignore_missing: bool) -> Result<()>
.map(|res| {
if ignore_missing && res.status() == StatusCode::NOT_FOUND {
exit(0);
} else {
util::print_result(res, format!("App {}", &app), Verbs::delete)
}
else {
util::print_result(res, format!("App {}", &app), Verbs::delete)
}
})
}

Expand Down
19 changes: 10 additions & 9 deletions src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ pub fn parse_arguments() -> ArgMatches<'static> {
.about("delete a device.")
.arg(&resource_id_arg)
.arg(&app_id_arg)
.arg(&ignore_missing)
.arg(&ignore_missing),
)
.subcommand(
SubCommand::with_name(Resources::app.as_ref())
.about("delete an app.")
.arg(&resource_id_arg)
.arg(&ignore_missing)
.arg(&ignore_missing),
),
)
.subcommand(
Expand Down Expand Up @@ -449,13 +449,14 @@ pub fn parse_arguments() -> ArgMatches<'static> {
SubCommand::with_name(Other_commands::endpoints.as_ref())
.about("List drogue-cloud available endpoints.")
.aliases(&["-e", "endpoint", "--endpoints"])
.arg( Arg::with_name(Other_commands::endpoints.as_ref())
.takes_value(true)
.required(false)
.help("Specify an endpoint name to get only it's address.")
.value_name("endpoint_name")
)
)
.arg(
Arg::with_name(Other_commands::endpoints.as_ref())
.takes_value(true)
.required(false)
.help("Specify an endpoint name to get only it's address.")
.value_name("endpoint_name"),
),
),
)
.subcommand(
SubCommand::with_name(Other_commands::context.as_ref())
Expand Down
13 changes: 9 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use std::{env, fs::create_dir_all, fs::write, fs::File, path::Path, process::exi

use crate::AppId;
use chrono::{DateTime, Utc};
use core::fmt;
use dirs::config_dir;
use oauth2::basic::BasicTokenResponse;
use tabular::{Row, Table};
use url::Url;
use core::fmt;

pub type ContextId = String;

Expand Down Expand Up @@ -42,7 +42,7 @@ impl Config {
Config {
active_context: String::new(),
contexts: Vec::new(),
// active_ctx_ref: None,
// active_ctx_ref: None,
}
}
pub fn from(path: Option<&str>) -> Result<Config> {
Expand All @@ -55,7 +55,7 @@ impl Config {
let config: Config =
serde_yaml::from_reader(file).context("Invalid configuration file.")?;

// config.active_ctx_ref = config.get_active_context().ok();
// config.active_ctx_ref = config.get_active_context().ok();
Ok(config)
}

Expand Down Expand Up @@ -219,7 +219,12 @@ impl Config {

impl fmt::Display for Config {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", serde_yaml::to_string(&self).unwrap_or("Cannot deserialize the config. The file may be corrupted.".to_string()))
write!(
f,
"{}",
serde_yaml::to_string(&self)
.unwrap_or("Cannot deserialize the config. The file may be corrupted.".to_string())
)
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ fn craft_url(base: &Url, app_id: &str, device_id: Option<&str>) -> String {
)
}

pub fn delete(config: &Context, app: AppId, device_id: DeviceId, ignore_missing: bool) -> Result<()> {
pub fn delete(
config: &Context,
app: AppId,
device_id: DeviceId,
ignore_missing: bool,
) -> Result<()> {
let client = Client::new();
let url = craft_url(&config.registry_url, &app, Some(&device_id));

Expand Down
4 changes: 1 addition & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,7 @@ fn main() -> Result<()> {
.unwrap()
.to_string();
let resource = Resources::from_str(res);
let ignore_missing = command
.unwrap()
.is_present(Other_flags::ignore_missing);
let ignore_missing = command.unwrap().is_present(Other_flags::ignore_missing);

match resource? {
Resources::app => apps::delete(&context, id, ignore_missing),
Expand Down

0 comments on commit f066677

Please sign in to comment.