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
+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");
}
}