parse citadel.channel command line option

Option takes a string argument which identifies the channel which should
be expected when mounting images. The channel name can optionally be
followed by a colon and a hex encoded public key for the channel.
This commit is contained in:
Bruce Leidl 2019-01-05 20:22:36 -05:00
parent 2bab6a438f
commit d1ca341f9a

View File

@ -60,6 +60,36 @@ impl CommandLine {
CommandLine::var_exists("citadel.recovery")
}
pub fn channel() -> Option<&'static str> {
CommandLine::get_value("citadel.channel")
}
fn _channel() -> Option<(&'static str,Option<&'static str>)> {
if let Some(channel) = CommandLine::channel() {
let parts = channel.splitn(2, ":").collect::<Vec<_>>();
if parts.len() == 2 {
return Some((parts[0], Some(parts[1])))
}
return Some((channel, None));
}
None
}
pub fn channel_name() -> Option<&'static str> {
if let Some((name, _)) = CommandLine::_channel() {
return Some(name)
}
None
}
pub fn channel_pubkey() -> Option<&'static str> {
if let Some((_, pubkey)) = CommandLine::_channel() {
return pubkey
}
None
}
pub fn verbose() -> bool {
CommandLine::var_exists("citadel.verbose")
}