From a2719c8c7e855108ac73e8746e59cf9715fb1bfe Mon Sep 17 00:00:00 2001 From: Jan Lukas Gernert Date: Wed, 5 Apr 2023 08:43:00 +0200 Subject: [PATCH] first few cli args --- article_scraper_cli/Cargo.toml | 3 ++- article_scraper_cli/src/args.rs | 31 +++++++++++++++++++++++++++++++ article_scraper_cli/src/main.rs | 7 ++++++- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 article_scraper_cli/src/args.rs diff --git a/article_scraper_cli/Cargo.toml b/article_scraper_cli/Cargo.toml index 8a86cb8..5fdedc4 100644 --- a/article_scraper_cli/Cargo.toml +++ b/article_scraper_cli/Cargo.toml @@ -8,4 +8,5 @@ description = "Cli to use the article_scraper lib" repository = "https://gitlab.com/news-flash/article_scraper" [dependencies] -article_scraper = { path = "../article_scraper/" } \ No newline at end of file +article_scraper = { path = "../article_scraper/" } +clap = { version = "4.2", features = [ "derive" ] } \ No newline at end of file diff --git a/article_scraper_cli/src/args.rs b/article_scraper_cli/src/args.rs new file mode 100644 index 0000000..ffb1686 --- /dev/null +++ b/article_scraper_cli/src/args.rs @@ -0,0 +1,31 @@ +use clap::{command, Parser, Subcommand}; +use std::path::PathBuf; + +#[derive(Parser)] +#[command(author, version, about, long_about = None)] +pub struct Args { + /// Turn debug logging on + #[arg(short, long)] + debug: bool, + + #[command(subcommand)] + command: Option, + + /// Destination of resulting HTML file + #[arg(short, long, value_name = "FILE")] + output: Option, +} + +#[derive(Subcommand)] +enum Commands { + /// Only use the Readability parser + Readability { + /// Source HTML file + #[arg(long, value_name = "FILE")] + html: Option, + + /// Source Url + #[arg(long, value_name = "URL")] + source_url: Option, + }, +} diff --git a/article_scraper_cli/src/main.rs b/article_scraper_cli/src/main.rs index 8543ca6..be7f10e 100644 --- a/article_scraper_cli/src/main.rs +++ b/article_scraper_cli/src/main.rs @@ -1,3 +1,8 @@ +use clap::Parser; + +mod args; + pub fn main() { + let _args = args::Args::parse(); println!("hello world"); -} \ No newline at end of file +}