rhg: add Command trait for subcommands implemented by rhg
authorAntoine Cezar <antoine.cezar@octobus.net>
Mon, 22 Jun 2020 15:19:35 +0530
changeset 45002 bacf6c7ef01b
parent 45001 cf04f62d1579
child 45003 1b757f385549
rhg: add Command trait for subcommands implemented by rhg Normalizes the interface of the cli's commands Differential Revision: https://phab.mercurial-scm.org/D8611 Differential Revision: https://phab.mercurial-scm.org/D8648
rust/rhg/src/commands.rs
rust/rhg/src/error.rs
rust/rhg/src/main.rs
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/rhg/src/commands.rs	Mon Jun 22 15:19:35 2020 +0530
@@ -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(&self) -> Result<(), CommandError>;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/rhg/src/error.rs	Mon Jun 22 15:19:35 2020 +0530
@@ -0,0 +1,3 @@
+/// The error type for the Command trait
+#[derive(Debug, PartialEq)]
+pub struct CommandError {}
--- a/rust/rhg/src/main.rs	Fri Jun 05 10:28:58 2020 +0200
+++ b/rust/rhg/src/main.rs	Mon Jun 22 15:19:35 2020 +0530
@@ -1,3 +1,5 @@
+mod commands;
+mod error;
 mod exitcode;
 
 fn main() {