##// END OF EJS Templates
narrow: get the narrow patterns from the repository object instead of disk...
narrow: get the narrow patterns from the repository object instead of disk Relying on disk data make the transactionally of this change complicated, so let us start reading data from other API instead.

File last commit:

r50534:37bc3ede default
r51080:99296ca9 default
Show More
config.rs
37 lines | 1.0 KiB | application/rls-services+xml | RustLexer
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::Command {
clap::command!("config")
.arg(
Arg::new("name")
.help("the section.name to print")
.value_name("NAME")
.required(true),
)
.about(HELP_TEXT)
}
pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
let (section, name) = invocation
.subcommand_args
.get_one::<String>("name")
.expect("missing required CLI argument")
.as_bytes()
.split_2(b'.')
.ok_or_else(|| HgError::unsupported("hg config <section>"))?;
if let Some(value) = invocation.config.get(section, name) {
invocation.ui.write_stdout(&format_bytes!(b"{}\n", value))?;
Ok(())
} else {
Err(CommandError::Unsuccessful)
}
}