Patchwork D8611: rhg: add Command trait for subcommands implemented by rhg

login
register
mail settings
Submitter phabricator
Date June 5, 2020, 2:32 p.m.
Message ID <differential-rev-PHID-DREV-gf3x54vehyo65dchixld-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46472/
State Superseded
Headers show

Comments

phabricator - June 5, 2020, 2:32 p.m.
acezar created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Normalizes the interface of the cli's commands

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8611

AFFECTED FILES
  rust/rhg/src/commands/mod.rs
  rust/rhg/src/error.rs
  rust/rhg/src/main.rs

CHANGE DETAILS




To: acezar, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/rhg/src/main.rs b/rust/rhg/src/main.rs
--- a/rust/rhg/src/main.rs
+++ b/rust/rhg/src/main.rs
@@ -1,3 +1,5 @@ 
+mod commands;
+mod error;
 mod exitcode;
 
 fn main() {
diff --git a/rust/rhg/src/error.rs b/rust/rhg/src/error.rs
new file mode 100644
--- /dev/null
+++ b/rust/rhg/src/error.rs
@@ -0,0 +1,4 @@ 
+
+/// The error type for the Command trait
+#[derive(Debug, PartialEq)]
+pub struct CommandError {}
diff --git a/rust/rhg/src/commands/mod.rs b/rust/rhg/src/commands/mod.rs
new file mode 100644
--- /dev/null
+++ b/rust/rhg/src/commands/mod.rs
@@ -0,0 +1,8 @@ 
+use crate::error::CommandError;
+
+/// The common trait for rhg commands
+///
+/// Normalize the interface of the commands provided by rhg
+pub trait Command {
+    fn run() -> Result<(), CommandError>;
+}