##// END OF EJS Templates
setup: further improve the error path for version retrieval...
setup: further improve the error path for version retrieval This is a new take at the problem that 8d390a13474d tried to tackle. There was two issues after that previous improvement: - the 0.0+ version could survive a bit too long and reaching the installer version and staying there. - multiple use case where still failing. So the new code is better at: - always succeeding when running `make local` so that we can bootstrap a local version - no using that fallback outside of `make local` to avoid distribution of version with the buggy version number. The setup.py is a gigantic pile of spaghetti code, to the point where pastafarian pilgrim started knocking at its core. However I refrained from cleaning that up since the more to a `setup.cfg` means this code should be deleted soon™.

File last commit:

r50534:37bc3ede default
r50988:010a1e73 stable
Show More
config.rs
38 lines | 1.1 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::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)
}
pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
let (section, name) = invocation
.subcommand_args
.value_of("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)
}
}