From: Ruben Beltran del Rio Date: Fri, 23 Feb 2024 21:03:40 +0000 (+0000) Subject: Add help X-Git-Tag: 7.0.0~52 X-Git-Url: https://git.r.bdr.sh/rbdr/blog/commitdiff_plain/2f579cf4c0d8ff95af78103783c7ca8f951cc797?hp=d620665f6b2e1ae5db4c98a09e35bd63133ae87f Add help --- diff --git a/src/command/add.rs b/src/command/add.rs index 36f25a0..4c80917 100644 --- a/src/command/add.rs +++ b/src/command/add.rs @@ -27,6 +27,6 @@ impl super::Command for Add { } fn help(&self) -> &'static str { - "\t\tCreates new blog post" + "\t\t\tCreates new blog post" } } diff --git a/src/command/generate.rs b/src/command/generate.rs index 943f2be..59babd5 100644 --- a/src/command/generate.rs +++ b/src/command/generate.rs @@ -27,6 +27,6 @@ impl super::Command for Generate { } fn help(&self) -> &'static str { - "\t\t\tGenerates the blog assets" + "\t\t\t\tGenerates the blog assets" } } diff --git a/src/command/help.rs b/src/command/help.rs index 9b98393..628fd5a 100644 --- a/src/command/help.rs +++ b/src/command/help.rs @@ -1,4 +1,6 @@ +use std::env::args; use std::io::Result; +use super::available_commands; pub struct Help; @@ -13,8 +15,16 @@ impl super::Command for Help { vec![] } - fn execute(&self, input: Option<&String>) -> Result<()> { - println!("Help: {:?}!", input); + 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(()) } diff --git a/src/command/publish.rs b/src/command/publish.rs index d8ca949..d6116a4 100644 --- a/src/command/publish.rs +++ b/src/command/publish.rs @@ -27,6 +27,6 @@ impl super::Command for Publish { } fn help(&self) -> &'static str { - "\tPublishes the blog to a remote host." + "\t\tPublishes the blog to a remote host" } } diff --git a/src/command/publish_archive.rs b/src/command/publish_archive.rs index 4275c38..6b98b1a 100644 --- a/src/command/publish_archive.rs +++ b/src/command/publish_archive.rs @@ -27,6 +27,6 @@ impl super::Command for PublishArchive { } fn help(&self) -> &'static str { - "\tPublishes the archive to a remote host." + "\tPublishes the archive to a remote host" } } diff --git a/src/command/sync_down.rs b/src/command/sync_down.rs index a0c713b..c00b01a 100644 --- a/src/command/sync_down.rs +++ b/src/command/sync_down.rs @@ -27,7 +27,7 @@ impl super::Command for SyncDown { } fn help(&self) -> &'static str { - "\t\t\tPulls from the git remote if configured" + "\t\t\t\tPulls from the git remote if configured" } } diff --git a/src/command/sync_up.rs b/src/command/sync_up.rs index cf49518..d35ce7f 100644 --- a/src/command/sync_up.rs +++ b/src/command/sync_up.rs @@ -27,6 +27,6 @@ impl super::Command for SyncUp { } fn help(&self) -> &'static str { - "\t\t\t\tPushes to the git remote if configured." + "\t\t\t\tPushes to the git remote if configured" } }