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"
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
[[package]]
name = "news"
version = "0.1.0"
dependencies = [
"chrono",
"colored",
"reqwest",
"scraper",
]
[[package]]
name = "nodrop"
version = "0.1.14"
@@ -1075,16 +1085,6 @@ dependencies = [
"winreg",
]
[[package]]
name = "rust-tldr-news"
version = "0.1.0"
dependencies = [
"chrono",
"colored",
"reqwest",
"scraper",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
+1 -1
View File
@@ -1,5 +1,5 @@
[package]
name = "rust-tldr-news"
name = "news"
version = "0.1.0"
edition = "2021"
+7 -1
View File
@@ -19,4 +19,10 @@ curl ... | sh
# 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);
if args.len() == 1 {
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());
print_help();
return;
}
@@ -46,10 +39,22 @@ fn main() {
let command = &args.get(1).unwrap();
match command.as_str() {
"today" => get_and_display_today_news(),
"help" => print_help(),
_ => 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() {
// format to 2023-06-05
let today = Local::now();
@@ -83,4 +88,3 @@ fn get_and_display_today_news() {
println!("\n");
}
}