##// END OF EJS Templates
tests: Add `--rhg` and `--with-rhg=<path>` options for `run-tests.py`...
tests: Add `--rhg` and `--with-rhg=<path>` options for `run-tests.py` They are mostly equivalent to the corresponding `chg` options. For now, many tests are still failing in this configuration. It is *not* run on CI. Differential Revision: https://phab.mercurial-scm.org/D10095

File last commit:

r47423:7284b524 default
r47426:fb236859 default
Show More
config.rs
36 lines | 1.0 KiB | application/rls-services+xml | RustLexer
Simon Sapin
rhg: add limited support for the `config` sub-command...
r47255 use crate::error::CommandError;
use clap::Arg;
use format_bytes::format_bytes;
use hg::errors::HgError;
use hg::utils::SliceExt;
pub const HELP_TEXT: &str = "
With one argument of the form section.name, print just the value of that config item.
";
pub fn args() -> clap::App<'static, 'static> {
clap::SubCommand::with_name("config")
.arg(
Arg::with_name("name")
.help("the section.name to print")
.value_name("NAME")
.required(true)
.takes_value(true),
)
.about(HELP_TEXT)
}
Simon Sapin
rhg: Group values passed to every sub-command into a struct...
r47334 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
let (section, name) = invocation
.subcommand_args
Simon Sapin
rhg: add limited support for the `config` sub-command...
r47255 .value_of("name")
.expect("missing required CLI argument")
.as_bytes()
.split_2(b'.')
.ok_or_else(|| HgError::abort(""))?;
Simon Sapin
rhg: Make configuration available as early as possible in main()...
r47423 let value = invocation.config.get(section, name).unwrap_or(b"");
Simon Sapin
rhg: add limited support for the `config` sub-command...
r47255
Simon Sapin
rhg: Group values passed to every sub-command into a struct...
r47334 invocation.ui.write_stdout(&format_bytes!(b"{}\n", value))?;
Simon Sapin
rhg: add limited support for the `config` sub-command...
r47255 Ok(())
}