root.rs
30 lines
| 755 B
| application/rls-services+xml
|
RustLexer
Antoine Cezar
|
r45922 | use crate::error::CommandError; | ||
Antoine Cezar
|
r45592 | use crate::ui::Ui; | ||
Simon Sapin
|
r47250 | use clap::ArgMatches; | ||
Raphaël Gomès
|
r46598 | use format_bytes::format_bytes; | ||
Simon Sapin
|
r47213 | use hg::config::Config; | ||
Simon Sapin
|
r46782 | use hg::repo::Repo; | ||
Antoine Cezar
|
r45592 | use hg::utils::files::get_bytes_from_path; | ||
Simon Sapin
|
r47253 | use std::path::Path; | ||
Antoine Cezar
|
r45592 | |||
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
|
r47250 | pub fn run( | ||
ui: &Ui, | ||||
config: &Config, | ||||
Simon Sapin
|
r47253 | repo_path: Option<&Path>, | ||
Simon Sapin
|
r47250 | _args: &ArgMatches, | ||
) -> Result<(), CommandError> { | ||||
Simon Sapin
|
r47253 | let repo = Repo::find(config, repo_path)?; | ||
Simon Sapin
|
r47250 | let bytes = get_bytes_from_path(repo.working_directory_path()); | ||
ui.write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?; | ||||
Ok(()) | ||||
Antoine Cezar
|
r45592 | } | ||