Skip to content

Commit eb045dc

Browse files
committed
update the binary to include the new options
1 parent 2727905 commit eb045dc

File tree

4 files changed

+114
-17
lines changed

4 files changed

+114
-17
lines changed

Cargo.lock

Lines changed: 90 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ ignore = "0.4.18"
4646
postgres-types = { version = "0.2.4", features = ["derive"] }
4747
cron = { version = "0.12.0" }
4848
bytes = "1.1.0"
49+
structopt = "0.3.26"
4950

5051
[dependencies.serde]
5152
version = "1"

src/bin/project_goals.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
1+
use structopt::StructOpt;
12
use triagebot::{github::GithubClient, handlers::project_goals};
23

4+
/// A basic example
5+
#[derive(StructOpt, Debug)]
6+
struct Opt {
7+
/// If specified, no messages are sent.
8+
#[structopt(long)]
9+
dry_run: bool,
10+
11+
/// Goals with an updated within this threshold will not be pinged.
12+
days_threshold: i64,
13+
14+
/// A string like "on Sep-5" when the update blog post will be written.
15+
next_meeting_date: String,
16+
}
17+
318
#[tokio::main(flavor = "current_thread")]
419
async fn main() -> anyhow::Result<()> {
520
dotenv::dotenv().ok();
621
tracing_subscriber::fmt::init();
722

8-
let mut dry_run = false;
9-
10-
for arg in std::env::args().skip(1) {
11-
match arg.as_str() {
12-
"--dry-run" => dry_run = true,
13-
_ => {
14-
eprintln!("Usage: project_goals [--dry-run]");
15-
std::process::exit(1);
16-
}
17-
}
18-
}
19-
23+
let opt = Opt::from_args();
2024
let gh = GithubClient::new_from_env();
21-
project_goals::ping_project_goals_owners(&gh, dry_run).await?;
25+
project_goals::ping_project_goals_owners(
26+
&gh,
27+
opt.dry_run,
28+
opt.days_threshold,
29+
&opt.next_meeting_date,
30+
) .await?;
2231

2332
Ok(())
2433
}

src/handlers/project_goals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::jobs::Job;
66
use crate::zulip::to_zulip_id;
77
use anyhow::Context as _;
88
use async_trait::async_trait;
9-
use chrono::{DateTime, Datelike, NaiveDate, NaiveDateTime, NaiveTime, Utc};
9+
use chrono::{Datelike, NaiveDate, Utc};
1010
use tracing::{self as log};
1111

1212
use super::Context;

0 commit comments

Comments
 (0)