aboutsummaryrefslogtreecommitdiff
path: root/src/command
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2024-02-23 20:37:39 +0000
committerRuben Beltran del Rio <git@r.bdr.sh>2024-02-23 20:37:39 +0000
commitd620665f6b2e1ae5db4c98a09e35bd63133ae87f (patch)
tree964bf044d3e1ae880c65d252e7c702f81874f2bc /src/command
parent72c91149425d45b0517bda929d459fc02f5603cc (diff)
Add logic skeleton for rust version
Diffstat (limited to 'src/command')
-rw-r--r--src/command/add.rs32
-rw-r--r--src/command/add_remote.rs32
-rw-r--r--src/command/generate.rs32
-rw-r--r--src/command/help.rs32
-rw-r--r--src/command/mod.rs49
-rw-r--r--src/command/publish.rs32
-rw-r--r--src/command/publish_archive.rs32
-rw-r--r--src/command/remove_remote.rs32
-rw-r--r--src/command/sync_down.rs33
-rw-r--r--src/command/sync_up.rs32
-rw-r--r--src/command/update.rs33
-rw-r--r--src/command/version.rs32
12 files changed, 403 insertions, 0 deletions
diff --git a/src/command/add.rs b/src/command/add.rs
new file mode 100644
index 0000000..36f25a0
--- /dev/null
+++ b/src/command/add.rs
@@ -0,0 +1,32 @@
+use std::io::Result;
+
+pub struct Add;
+
+impl Add {
+ pub fn new() -> Self {
+ Add
+ }
+}
+
+impl super::Command for Add {
+ fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn execute(&self, input: Option<&String>) -> Result<()> {
+ println!("Add: {:?}!", input);
+ return Ok(())
+ }
+
+ fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn command(&self) -> &'static str {
+ "add"
+ }
+
+ fn help(&self) -> &'static str {
+ "<path_to_post>\t\tCreates new blog post"
+ }
+}
diff --git a/src/command/add_remote.rs b/src/command/add_remote.rs
new file mode 100644
index 0000000..3d90103
--- /dev/null
+++ b/src/command/add_remote.rs
@@ -0,0 +1,32 @@
+use std::io::Result;
+
+pub struct AddRemote;
+
+impl AddRemote {
+ pub fn new() -> Self {
+ AddRemote
+ }
+}
+
+impl super::Command for AddRemote {
+ fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn execute(&self, input: Option<&String>) -> Result<()> {
+ println!("Add Remote: {:?}!", input);
+ return Ok(())
+ }
+
+ fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn command(&self) -> &'static str {
+ "add-remote"
+ }
+
+ fn help(&self) -> &'static str {
+ "<git_url>\t\tAdds or updates a git remote to sync with"
+ }
+}
diff --git a/src/command/generate.rs b/src/command/generate.rs
new file mode 100644
index 0000000..943f2be
--- /dev/null
+++ b/src/command/generate.rs
@@ -0,0 +1,32 @@
+use std::io::Result;
+
+pub struct Generate;
+
+impl Generate {
+ pub fn new() -> Self {
+ Generate
+ }
+}
+
+impl super::Command for Generate {
+ fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn execute(&self, input: Option<&String>) -> Result<()> {
+ println!("GENERATE! {:?}", input);
+ return Ok(())
+ }
+
+ fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn command(&self) -> &'static str {
+ "generate"
+ }
+
+ fn help(&self) -> &'static str {
+ "\t\t\tGenerates the blog assets"
+ }
+}
diff --git a/src/command/help.rs b/src/command/help.rs
new file mode 100644
index 0000000..9b98393
--- /dev/null
+++ b/src/command/help.rs
@@ -0,0 +1,32 @@
+use std::io::Result;
+
+pub struct Help;
+
+impl Help {
+ pub fn new() -> Self {
+ Help
+ }
+}
+
+impl super::Command for Help {
+ fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn execute(&self, input: Option<&String>) -> Result<()> {
+ println!("Help: {:?}!", input);
+ return Ok(())
+ }
+
+ fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn command(&self) -> &'static str {
+ "help"
+ }
+
+ fn help(&self) -> &'static str {
+ "\t\t\t\tPrints this help"
+ }
+}
diff --git a/src/command/mod.rs b/src/command/mod.rs
new file mode 100644
index 0000000..c207754
--- /dev/null
+++ b/src/command/mod.rs
@@ -0,0 +1,49 @@
+pub mod add;
+pub mod generate;
+pub mod update;
+pub mod publish;
+pub mod publish_archive;
+pub mod add_remote;
+pub mod remove_remote;
+pub mod sync_up;
+pub mod sync_down;
+pub mod version;
+pub mod help;
+
+use std::io::Result;
+
+use add::Add;
+use generate::Generate;
+use update::Update;
+use publish::Publish;
+use publish_archive::PublishArchive;
+use add_remote::AddRemote;
+use remove_remote::RemoveRemote;
+use sync_up::SyncUp;
+use sync_down::SyncDown;
+use version::Version;
+use help::Help;
+
+pub trait Command {
+ fn before_dependencies(&self) -> Vec<Box<dyn Command>>;
+ fn execute(&self, input: Option<&String>) -> Result<()>;
+ fn after_dependencies(&self) -> Vec<Box<dyn Command>>;
+ fn command(&self) -> &'static str;
+ fn help(&self) -> &'static str;
+}
+
+pub fn available_commands() -> Vec<Box<dyn Command>> {
+ vec![
+ Box::new(Add::new()),
+ Box::new(Generate::new()),
+ Box::new(Update::new()),
+ Box::new(Publish::new()),
+ Box::new(PublishArchive::new()),
+ Box::new(AddRemote::new()),
+ Box::new(RemoveRemote::new()),
+ Box::new(SyncUp::new()),
+ Box::new(SyncDown::new()),
+ Box::new(Version::new()),
+ Box::new(Help::new())
+ ]
+}
diff --git a/src/command/publish.rs b/src/command/publish.rs
new file mode 100644
index 0000000..d8ca949
--- /dev/null
+++ b/src/command/publish.rs
@@ -0,0 +1,32 @@
+use std::io::Result;
+
+pub struct Publish;
+
+impl Publish {
+ pub fn new() -> Self {
+ Publish
+ }
+}
+
+impl super::Command for Publish {
+ fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn execute(&self, input: Option<&String>) -> Result<()> {
+ println!("Publish: {:?}!", input);
+ return Ok(())
+ }
+
+ fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn command(&self) -> &'static str {
+ "publish"
+ }
+
+ fn help(&self) -> &'static str {
+ "<destination>\tPublishes the blog to a remote host."
+ }
+}
diff --git a/src/command/publish_archive.rs b/src/command/publish_archive.rs
new file mode 100644
index 0000000..4275c38
--- /dev/null
+++ b/src/command/publish_archive.rs
@@ -0,0 +1,32 @@
+use std::io::Result;
+
+pub struct PublishArchive;
+
+impl PublishArchive {
+ pub fn new() -> Self {
+ PublishArchive
+ }
+}
+
+impl super::Command for PublishArchive {
+ fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn execute(&self, input: Option<&String>) -> Result<()> {
+ println!("Publish Archive: {:?}!", input);
+ return Ok(())
+ }
+
+ fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn command(&self) -> &'static str {
+ "publish-archive"
+ }
+
+ fn help(&self) -> &'static str {
+ "<destination>\tPublishes the archive to a remote host."
+ }
+}
diff --git a/src/command/remove_remote.rs b/src/command/remove_remote.rs
new file mode 100644
index 0000000..cfc5cdb
--- /dev/null
+++ b/src/command/remove_remote.rs
@@ -0,0 +1,32 @@
+use std::io::Result;
+
+pub struct RemoveRemote;
+
+impl RemoveRemote {
+ pub fn new() -> Self {
+ RemoveRemote
+ }
+}
+
+impl super::Command for RemoveRemote {
+ fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn execute(&self, input: Option<&String>) -> Result<()> {
+ println!("Remove Remote: {:?}!", input);
+ return Ok(())
+ }
+
+ fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn command(&self) -> &'static str {
+ "remove-remote"
+ }
+
+ fn help(&self) -> &'static str {
+ "\t\t\tRemoves the git remote"
+ }
+}
diff --git a/src/command/sync_down.rs b/src/command/sync_down.rs
new file mode 100644
index 0000000..a0c713b
--- /dev/null
+++ b/src/command/sync_down.rs
@@ -0,0 +1,33 @@
+use std::io::Result;
+
+pub struct SyncDown;
+
+impl SyncDown {
+ pub fn new() -> Self {
+ SyncDown
+ }
+}
+
+impl super::Command for SyncDown {
+ fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn execute(&self, input: Option<&String>) -> Result<()> {
+ println!("Sync Down: {:?}!", input);
+ return Ok(())
+ }
+
+ fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn command(&self) -> &'static str {
+ "sync-down"
+ }
+
+ fn help(&self) -> &'static str {
+ "\t\t\tPulls from the git remote if configured"
+ }
+}
+
diff --git a/src/command/sync_up.rs b/src/command/sync_up.rs
new file mode 100644
index 0000000..cf49518
--- /dev/null
+++ b/src/command/sync_up.rs
@@ -0,0 +1,32 @@
+use std::io::Result;
+
+pub struct SyncUp;
+
+impl SyncUp {
+ pub fn new() -> Self {
+ SyncUp
+ }
+}
+
+impl super::Command for SyncUp {
+ fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn execute(&self, input: Option<&String>) -> Result<()> {
+ println!("Sync Up: {:?}!", input);
+ return Ok(())
+ }
+
+ fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn command(&self) -> &'static str {
+ "sync-up"
+ }
+
+ fn help(&self) -> &'static str {
+ "\t\t\t\tPushes to the git remote if configured."
+ }
+}
diff --git a/src/command/update.rs b/src/command/update.rs
new file mode 100644
index 0000000..d251093
--- /dev/null
+++ b/src/command/update.rs
@@ -0,0 +1,33 @@
+use std::io::Result;
+
+pub struct Update;
+
+impl Update {
+ pub fn new() -> Self {
+ Update
+ }
+}
+
+impl super::Command for Update {
+ fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn execute(&self, input: Option<&String>) -> Result<()> {
+ println!("Update: {:?}!", input);
+ return Ok(())
+ }
+
+ fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn command(&self) -> &'static str {
+ "update"
+ }
+
+ fn help(&self) -> &'static str {
+ "<path_to_post>\t\tUpdates latest blog post"
+ }
+}
+
diff --git a/src/command/version.rs b/src/command/version.rs
new file mode 100644
index 0000000..fae7596
--- /dev/null
+++ b/src/command/version.rs
@@ -0,0 +1,32 @@
+use std::io::Result;
+
+pub struct Version;
+
+impl Version {
+ pub fn new() -> Self {
+ Version
+ }
+}
+
+impl super::Command for Version {
+ fn before_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn execute(&self, input: Option<&String>) -> Result<()> {
+ println!("Version: {:?}!", input);
+ return Ok(())
+ }
+
+ fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {
+ vec![]
+ }
+
+ fn command(&self) -> &'static str {
+ "version"
+ }
+
+ fn help(&self) -> &'static str {
+ "\t\t\t\tPrints the version"
+ }
+}