adding help comand

This commit is contained in:
talksik
2023-06-02 11:27:07 -07:00
parent fccd8cf4ae
commit b411341375
4 changed files with 31 additions and 21 deletions
Generated
+10 -10
View File
@@ -689,6 +689,16 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
[[package]]
name = "news"
version = "0.1.0"
dependencies = [
"chrono",
"colored",
"reqwest",
"scraper",
]
[[package]] [[package]]
name = "nodrop" name = "nodrop"
version = "0.1.14" version = "0.1.14"
@@ -1075,16 +1085,6 @@ dependencies = [
"winreg", "winreg",
] ]
[[package]]
name = "rust-tldr-news"
version = "0.1.0"
dependencies = [
"chrono",
"colored",
"reqwest",
"scraper",
]
[[package]] [[package]]
name = "rustc_version" name = "rustc_version"
version = "0.4.0" version = "0.4.0"
+1 -1
View File
@@ -1,5 +1,5 @@
[package] [package]
name = "rust-tldr-news" name = "news"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
+7 -1
View File
@@ -19,4 +19,10 @@ curl ... | sh
# Usage # Usage
Show me todays news: `rust-tldr today` ```
$ news today
```
```
$ news help
```
+13 -9
View File
@@ -31,14 +31,7 @@ fn main() {
println!("args: {:?}", args); println!("args: {:?}", args);
if args.len() == 1 { if args.len() == 1 {
println!("About"); print_help();
println!(" news is a cli tool to get the latest tech news from tldr.tech");
println!("Usage");
println!("{}", " $ news today".green());
println!("{}", " $ news yesterday(not implemented)".blue());
println!("{}", " $ news help".red());
return; return;
} }
@@ -46,10 +39,22 @@ fn main() {
let command = &args.get(1).unwrap(); let command = &args.get(1).unwrap();
match command.as_str() { match command.as_str() {
"today" => get_and_display_today_news(), "today" => get_and_display_today_news(),
"help" => print_help(),
_ => println!("unknown command. use `news help` to see available commands"), _ => println!("unknown command. use `news help` to see available commands"),
} }
} }
fn print_help() {
println!("About");
println!(" news is a cli tool to get the latest tech news from tldr.tech");
println!("Usage");
println!("{}", " $ news today".green());
println!("{}", " $ news yesterday(not implemented)".blue());
println!("{}", " $ news help".red());
}
fn get_and_display_today_news() { fn get_and_display_today_news() {
// format to 2023-06-05 // format to 2023-06-05
let today = Local::now(); let today = Local::now();
@@ -83,4 +88,3 @@ fn get_and_display_today_news() {
println!("\n"); println!("\n");
} }
} }