mirror of
https://github.com/davegallant/rfd-notify.git
synced 2025-08-06 08:43:39 +00:00
Bump clap from 2.34.0 to 4.0.9 (#212)
* Bump clap from 2.34.0 to 4.0.9 Bumps [clap](https://github.com/clap-rs/clap) from 2.34.0 to 4.0.9. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v2.34.0...v4.0.9) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Make changes so that clap v4 works * Cargo fmt Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Dave Gallant <davegallant@gmail.com>
This commit is contained in:
44
src/main.rs
44
src/main.rs
@@ -9,47 +9,35 @@ mod db;
|
||||
mod mail;
|
||||
mod rfd;
|
||||
|
||||
use clap::{App, Arg};
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
// Specify path to config
|
||||
#[arg(short, long, default_value = "./config.yml")]
|
||||
config: String,
|
||||
|
||||
// Specify path to where the embedded database is stored
|
||||
#[arg(short, long, default_value = "./deals_db")]
|
||||
dbpath: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
setup_logging();
|
||||
|
||||
debug!("Starting rfd-notify");
|
||||
|
||||
let app = App::new("rfd-notify")
|
||||
.version("0.1.2")
|
||||
.about("Send emails based on regular expressions")
|
||||
.args(&[
|
||||
Arg::with_name("config")
|
||||
.default_value("./config.yml")
|
||||
.required(true)
|
||||
.takes_value(true)
|
||||
.short("c")
|
||||
.help("Specify path to config")
|
||||
.long("config"),
|
||||
Arg::with_name("dbpath")
|
||||
.default_value("./deals_db")
|
||||
.takes_value(true)
|
||||
.short("d")
|
||||
.help("Specify path to where the embedded database is stored")
|
||||
.long("dbpath"),
|
||||
]);
|
||||
let args = Args::parse();
|
||||
|
||||
debug!("Finding matches...");
|
||||
|
||||
let matches = app.get_matches();
|
||||
|
||||
let config = matches.value_of("config").unwrap();
|
||||
let parsed_config = config::load(config);
|
||||
let parsed_config = config::load(&args.config);
|
||||
|
||||
info!("{:?}\n", parsed_config);
|
||||
let hot_deals = rfd::get_hot_deals().map_err(|err| error!("{:?}", err)).ok();
|
||||
let parsed_deals = rfd::parse_hot_deals(&hot_deals.unwrap());
|
||||
rfd::match_deals(
|
||||
parsed_deals,
|
||||
parsed_config,
|
||||
matches.value_of("dbpath").unwrap(),
|
||||
);
|
||||
rfd::match_deals(parsed_deals, parsed_config, &args.dbpath);
|
||||
info!("Complete")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user