diff --git a/src/delivery/cli/api.rs b/src/delivery/cli/api.rs index e2d441b8..fd5e2c79 100644 --- a/src/delivery/cli/api.rs +++ b/src/delivery/cli/api.rs @@ -15,7 +15,7 @@ // limitations under the License. // use clap::{App, Arg, ArgMatches, SubCommand}; -use cli::arguments::{api_port_arg, config_path_arg, u_e_s_o_args, a2_mode_arg, value_of}; +use cli::arguments::{a2_mode_arg, api_port_arg, config_path_arg, u_e_s_o_args, value_of}; use cli::Options; use config::Config; use types::DeliveryResult; @@ -58,7 +58,11 @@ impl<'n> ApiClapOptions<'n> { api_port: value_of(&matches, "api-port"), ent: value_of(&matches, "ent"), user: value_of(&matches, "user"), - a2_mode: if matches.is_present("a2-mode") { Some(true) } else { None }, + a2_mode: if matches.is_present("a2-mode") { + Some(true) + } else { + None + }, } } } diff --git a/src/delivery/cli/clone.rs b/src/delivery/cli/clone.rs index 8a0e18f5..9e5d1de6 100644 --- a/src/delivery/cli/clone.rs +++ b/src/delivery/cli/clone.rs @@ -15,7 +15,7 @@ // limitations under the License. // use clap::{App, ArgMatches, SubCommand}; -use cli::arguments::{project_specific_args, u_e_s_o_args, a2_mode_arg, value_of}; +use cli::arguments::{a2_mode_arg, project_specific_args, u_e_s_o_args, value_of}; use cli::Options; use config::Config; use fips; @@ -66,7 +66,11 @@ impl<'n> CloneClapOptions<'n> { fips: matches.is_present("fips"), fips_git_port: value_of(&matches, "fips-git-port"), fips_custom_cert_filename: value_of(&matches, "fips-custom-cert-filename"), - a2_mode: if matches.is_present("a2-mode") { Some(true) } else { None }, + a2_mode: if matches.is_present("a2-mode") { + Some(true) + } else { + None + }, } } } @@ -80,7 +84,7 @@ impl<'n> Options for CloneClapOptions<'n> { .set_organization(&self.org) .set_project(&self.project) .set_a2_mode_if_def(self.a2_mode); - + if new_config.project.is_none() { new_config.project = project::project_from_cwd().ok(); } diff --git a/src/delivery/cli/init.rs b/src/delivery/cli/init.rs index df44b638..56a8921d 100644 --- a/src/delivery/cli/init.rs +++ b/src/delivery/cli/init.rs @@ -16,8 +16,8 @@ // use clap::{App, ArgMatches, SubCommand}; use cli::arguments::{ - config_path_arg, config_project_arg, local_arg, no_open_arg, pipeline_arg, project_arg, - project_specific_args, scp_args, u_e_s_o_args, a2_mode_arg, value_of, + a2_mode_arg, config_path_arg, config_project_arg, local_arg, no_open_arg, pipeline_arg, + project_arg, project_specific_args, scp_args, u_e_s_o_args, value_of, }; use cli::Options; use config::Config; @@ -97,7 +97,11 @@ impl<'n> InitClapOptions<'n> { fips: matches.is_present("fips"), fips_git_port: value_of(&matches, "fips-git-port"), fips_custom_cert_filename: value_of(&matches, "fips-custom-cert-filename"), - a2_mode: if matches.is_present("a2-mode") { Some(true) } else { None }, + a2_mode: if matches.is_present("a2-mode") { + Some(true) + } else { + None + }, } } } diff --git a/src/delivery/cli/job.rs b/src/delivery/cli/job.rs index 9c7ea87e..85041335 100644 --- a/src/delivery/cli/job.rs +++ b/src/delivery/cli/job.rs @@ -107,7 +107,11 @@ impl<'n> JobClapOptions<'n> { fips: matches.is_present("fips"), fips_git_port: value_of(&matches, "fips-git-port"), fips_custom_cert_filename: value_of(&matches, "fips-custom-cert-filename"), - a2_mode: if matches.is_present("a2-mode") { Some(true) } else { None }, + a2_mode: if matches.is_present("a2-mode") { + Some(true) + } else { + None + }, } } } diff --git a/src/delivery/cli/setup.rs b/src/delivery/cli/setup.rs index f74aa281..7a1fd2e7 100644 --- a/src/delivery/cli/setup.rs +++ b/src/delivery/cli/setup.rs @@ -61,7 +61,11 @@ impl<'n> SetupClapOptions<'n> { path: value_of(&matches, "config-path"), pipeline: value_of(&matches, "pipeline"), project: value_of(&matches, "project"), - a2_mode: if matches.is_present("a2-mode") { Some(true) } else { None }, + a2_mode: if matches.is_present("a2-mode") { + Some(true) + } else { + None + }, } } } diff --git a/src/delivery/config/mod.rs b/src/delivery/config/mod.rs index 94584e7e..757af8f2 100644 --- a/src/delivery/config/mod.rs +++ b/src/delivery/config/mod.rs @@ -74,12 +74,11 @@ impl Default for Config { fips: None, fips_git_port: None, fips_custom_cert_filename: None, - a2_mode: None + a2_mode: None, } } } - macro_rules! config_accessor_for { ($name:ident, $set_name:ident, $err_msg:expr) => { impl Config { @@ -128,7 +127,7 @@ macro_rules! config_bool_accessor_for { self } } - + paste::item! { pub fn [](mut self, $name: bool) -> Config { self.$name = Some($name); @@ -139,8 +138,6 @@ macro_rules! config_bool_accessor_for { }; } - - config_accessor_for!( server, set_server, @@ -212,7 +209,6 @@ config_bool_accessor_for!( "You did not set the a2_mode. Set this value in your cli.toml." ); - impl Config { /// Return the host and port at which we can access the Delivery /// API. By default, we assume the use of HTTPS on the standard @@ -526,7 +522,6 @@ mod tests { ); } - #[test] fn test_api_base_resource_with_port_with_a2() { let mut conf = Config::default(); @@ -545,7 +540,10 @@ mod tests { conf.server = Some("127.0.0.1".to_string()); conf.a2_mode = Some(true); assert!(conf.api_port.is_none()); - assert_eq!("127.0.0.1/workflow".to_string(), conf.api_base_resource().unwrap()); + assert_eq!( + "127.0.0.1/workflow".to_string(), + conf.api_base_resource().unwrap() + ); } #[test]