##// END OF EJS Templates
rhg: Fall back to Python on unsupported `rhg config <section>`...
Simon Sapin -
r47460:92e3cfd6 default
parent child Browse files
Show More
@@ -1,36 +1,36 b''
1 1 use crate::error::CommandError;
2 2 use clap::Arg;
3 3 use format_bytes::format_bytes;
4 4 use hg::errors::HgError;
5 5 use hg::utils::SliceExt;
6 6
7 7 pub const HELP_TEXT: &str = "
8 8 With one argument of the form section.name, print just the value of that config item.
9 9 ";
10 10
11 11 pub fn args() -> clap::App<'static, 'static> {
12 12 clap::SubCommand::with_name("config")
13 13 .arg(
14 14 Arg::with_name("name")
15 15 .help("the section.name to print")
16 16 .value_name("NAME")
17 17 .required(true)
18 18 .takes_value(true),
19 19 )
20 20 .about(HELP_TEXT)
21 21 }
22 22
23 23 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
24 24 let (section, name) = invocation
25 25 .subcommand_args
26 26 .value_of("name")
27 27 .expect("missing required CLI argument")
28 28 .as_bytes()
29 29 .split_2(b'.')
30 .ok_or_else(|| HgError::abort(""))?;
30 .ok_or_else(|| HgError::unsupported("hg config <section>"))?;
31 31
32 32 let value = invocation.config.get(section, name).unwrap_or(b"");
33 33
34 34 invocation.ui.write_stdout(&format_bytes!(b"{}\n", value))?;
35 35 Ok(())
36 36 }
General Comments 0
You need to be logged in to leave comments. Login now