Mercurial > public > mercurial-scm > hg
diff rust/rhg/src/commands/root.rs @ 45438:ed95ccc94333
rhg: pass `ui` to `Command` `run`
Allow implementation of `From<clap::ArgMatches> for Command`
Differential Revision: https://phab.mercurial-scm.org/D8954
author | Antoine Cezar <antoine.cezar@octobus.net> |
---|---|
date | Tue, 04 Aug 2020 16:11:23 +0200 |
parents | 5dbf875b3275 |
children | fada33872b5b |
line wrap: on
line diff
--- a/rust/rhg/src/commands/root.rs Mon Aug 03 11:55:59 2020 +0200 +++ b/rust/rhg/src/commands/root.rs Tue Aug 04 16:11:23 2020 +0200 @@ -10,24 +10,22 @@ Returns 0 on success. "; -pub struct RootCommand<'a> { - ui: &'a Ui, -} +pub struct RootCommand {} -impl<'a> RootCommand<'a> { - pub fn new(ui: &'a Ui) -> Self { - RootCommand { ui } +impl RootCommand { + pub fn new() -> Self { + RootCommand {} } } -impl<'a> Command<'a> for RootCommand<'a> { - fn run(&self) -> Result<(), CommandError> { +impl Command for RootCommand { + fn run(&self, ui: &Ui) -> Result<(), CommandError> { let path_buf = FindRoot::new().run()?; let bytes = get_bytes_from_path(path_buf); // TODO use formating macro - self.ui.write_stdout(&[bytes.as_slice(), b"\n"].concat())?; + ui.write_stdout(&[bytes.as_slice(), b"\n"].concat())?; Ok(()) }