root.rs
32 lines
| 673 B
| application/rls-services+xml
|
RustLexer
|
r45592 | use crate::commands::Command; | ||
|
r45922 | use crate::error::CommandError; | ||
|
r45592 | use crate::ui::Ui; | ||
|
r46598 | use format_bytes::format_bytes; | ||
|
r46751 | use hg::operations::find_root; | ||
|
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. | ||||
"; | ||||
|
r46009 | pub struct RootCommand {} | ||
|
r45920 | |||
|
r46009 | impl RootCommand { | ||
pub fn new() -> Self { | ||||
RootCommand {} | ||||
|
r45920 | } | ||
|
r45592 | } | ||
|
r46009 | impl Command for RootCommand { | ||
fn run(&self, ui: &Ui) -> Result<(), CommandError> { | ||||
|
r46751 | let path_buf = find_root()?; | ||
|
r45592 | |||
let bytes = get_bytes_from_path(path_buf); | ||||
|
r46598 | ui.write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?; | ||
|
r45592 | |||
|
r45919 | Ok(()) | ||
|
r45592 | } | ||
} | ||||