root.rs
22 lines
| 608 B
| application/rls-services+xml
|
RustLexer
Antoine Cezar
|
r45922 | use crate::error::CommandError; | ||
Raphaël Gomès
|
r46598 | use format_bytes::format_bytes; | ||
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. | ||||
"; | ||||
Simon Sapin
|
r47251 | pub fn args() -> clap::App<'static, 'static> { | ||
clap::SubCommand::with_name("root").about(HELP_TEXT) | ||||
} | ||||
Simon Sapin
|
r47334 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { | ||
Simon Sapin
|
r47335 | let repo = invocation.repo?; | ||
Simon Sapin
|
r47250 | let bytes = get_bytes_from_path(repo.working_directory_path()); | ||
Simon Sapin
|
r47334 | invocation | ||
.ui | ||||
.write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?; | ||||
Simon Sapin
|
r47250 | Ok(()) | ||
Antoine Cezar
|
r45592 | } | ||