summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2019-07-12 15:48:53 +0200
committerPietro Albini <pietro@pietroalbini.org>2019-07-13 21:45:20 +0200
commit5bf01b4b591afebc978123e27ab682945fd215a8 (patch)
tree81a7b761f206c42570c69b20c135838abc58e0b9 /src
parent8578b7e3cdc93b583d5c25762ac36ec512c779f3 (diff)
add the --strict option to the check subcommand
Diffstat (limited to 'src')
-rw-r--r--src/main.rs9
-rw-r--r--src/validate.rs10
2 files changed, 13 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index c47f270..e46acae 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,7 +18,10 @@ use structopt::StructOpt;
#[structopt(name = "team", about = "manage the rust team members")]
enum Cli {
#[structopt(name = "check", help = "check if the configuration is correct")]
- Check,
+ Check {
+ #[structopt(long = "strict", help = "fail if optional checks are not executed")]
+ strict: bool,
+ },
#[structopt(
name = "add-person",
help = "add a new person from their GitHub profile"
@@ -65,8 +68,8 @@ fn run() -> Result<(), Error> {
let cli = Cli::from_args();
let data = Data::load()?;
match cli {
- Cli::Check => {
- crate::validate::validate(&data)?;
+ Cli::Check { strict } => {
+ crate::validate::validate(&data, strict)?;
}
Cli::AddPerson { ref github_name } => {
#[derive(serde::Serialize)]
diff --git a/src/validate.rs b/src/validate.rs
index 3965a58..82f2fee 100644
--- a/src/validate.rs
+++ b/src/validate.rs
@@ -27,7 +27,7 @@ static CHECKS: &[fn(&Data, &mut Vec<String>)] = &[
static GITHUB_CHECKS: &[fn(&Data, &GitHubApi, &mut Vec<String>)] = &[validate_github_usernames];
-pub(crate) fn validate(data: &Data) -> Result<(), Error> {
+pub(crate) fn validate(data: &Data, strict: bool) -> Result<(), Error> {
let mut errors = Vec::new();
for check in CHECKS {
@@ -41,8 +41,12 @@ pub(crate) fn validate(data: &Data) -> Result<(), Error> {
}
}
Err(err) => {
- warn!("couldn't perform checks relying on the GitHub API, some errors will not be detected");
- warn!("cause: {}", err);
+ if strict {
+ return Err(err);
+ } else {
+ warn!("couldn't perform checks relying on the GitHub API, some errors will not be detected");
+ warn!("cause: {}", err);
+ }
}
}