rust/rhg/src/commands/root.rs
changeset 46503 d8730ff51d5a
parent 46501 1ecaf09d9964
child 46592 80840b651721
equal deleted inserted replaced
46502:95d37db31479 46503:d8730ff51d5a
     3 use clap::ArgMatches;
     3 use clap::ArgMatches;
     4 use format_bytes::format_bytes;
     4 use format_bytes::format_bytes;
     5 use hg::config::Config;
     5 use hg::config::Config;
     6 use hg::repo::Repo;
     6 use hg::repo::Repo;
     7 use hg::utils::files::get_bytes_from_path;
     7 use hg::utils::files::get_bytes_from_path;
       
     8 use std::path::Path;
     8 
     9 
     9 pub const HELP_TEXT: &str = "
    10 pub const HELP_TEXT: &str = "
    10 Print the root directory of the current repository.
    11 Print the root directory of the current repository.
    11 
    12 
    12 Returns 0 on success.
    13 Returns 0 on success.
    17 }
    18 }
    18 
    19 
    19 pub fn run(
    20 pub fn run(
    20     ui: &Ui,
    21     ui: &Ui,
    21     config: &Config,
    22     config: &Config,
       
    23     repo_path: Option<&Path>,
    22     _args: &ArgMatches,
    24     _args: &ArgMatches,
    23 ) -> Result<(), CommandError> {
    25 ) -> Result<(), CommandError> {
    24     let repo = Repo::find(config)?;
    26     let repo = Repo::find(config, repo_path)?;
    25     let bytes = get_bytes_from_path(repo.working_directory_path());
    27     let bytes = get_bytes_from_path(repo.working_directory_path());
    26     ui.write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?;
    28     ui.write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?;
    27     Ok(())
    29     Ok(())
    28 }
    30 }