root.rs
32 lines
| 682 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; | ||
Raphaël Gomès
|
r46598 | use format_bytes::format_bytes; | ||
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); | ||||
Raphaël Gomès
|
r46598 | ui.write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?; | ||
Antoine Cezar
|
r45592 | |||
Antoine Cezar
|
r45919 | Ok(()) | ||
Antoine Cezar
|
r45592 | } | ||
} | ||||