use std::env::args; use std::io::Result; use super::available_commands; pub struct Help; impl Help { pub fn new() -> Self { Help } } impl super::Command for Help { fn before_dependencies(&self) -> Vec> { vec![] } fn execute(&self, _: Option<&String>) -> Result<()> { let arguments: Vec = args().collect(); let app_name = arguments.get(0).map_or("blog", |s| s.as_str()); let commands = available_commands(); println!("Usage:"); println!(""); for command in commands { print!("{} {} ", app_name, command.command()); println!("{}", command.help()); } return Ok(()) } fn after_dependencies(&self) -> Vec> { vec![] } fn command(&self) -> &'static str { "help" } fn help(&self) -> &'static str { "\t\t\t\tPrints this help" } }