root.rs
29 lines
| 677 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; | ||
Simon Sapin
|
r46782 | use hg::repo::Repo; | ||
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> { | ||||
Simon Sapin
|
r46782 | let repo = Repo::find()?; | ||
let bytes = get_bytes_from_path(repo.working_directory_path()); | ||||
Raphaël Gomès
|
r46598 | ui.write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?; | ||
Antoine Cezar
|
r45919 | Ok(()) | ||
Antoine Cezar
|
r45592 | } | ||
} | ||||