root.rs
32 lines
| 680 B
| application/rls-services+xml
|
RustLexer
Antoine Cezar
|
r45592 | use crate::commands::Command; | ||
Antoine Cezar
|
r45922 | use crate::error::CommandError; | ||
Antoine Cezar
|
r45592 | use crate::ui::Ui; | ||
Antoine Cezar
|
r45922 | use hg::operations::FindRoot; | ||
Antoine Cezar
|
r45592 | use hg::utils::files::get_bytes_from_path; | ||
pub const HELP_TEXT: &str = " | ||||
Print the root directory of the current repository. | ||||
Returns 0 on success. | ||||
"; | ||||
Antoine Cezar
|
r46009 | pub struct RootCommand {} | ||
Antoine Cezar
|
r45920 | |||
Antoine Cezar
|
r46009 | impl RootCommand { | ||
pub fn new() -> Self { | ||||
RootCommand {} | ||||
Antoine Cezar
|
r45920 | } | ||
Antoine Cezar
|
r45592 | } | ||
Antoine Cezar
|
r46009 | impl Command for RootCommand { | ||
fn run(&self, ui: &Ui) -> Result<(), CommandError> { | ||||
Antoine Cezar
|
r45922 | let path_buf = FindRoot::new().run()?; | ||
Antoine Cezar
|
r45592 | |||
let bytes = get_bytes_from_path(path_buf); | ||||
// TODO use formating macro | ||||
Antoine Cezar
|
r46009 | ui.write_stdout(&[bytes.as_slice(), b"\n"].concat())?; | ||
Antoine Cezar
|
r45592 | |||
Antoine Cezar
|
r45919 | Ok(()) | ||
Antoine Cezar
|
r45592 | } | ||
} | ||||