Generalize function.
This commit is contained in:
parent
7d2fab14f9
commit
092ba48e5a
@ -45,7 +45,7 @@ fn get(sq: Sq, cmd: config::get::Command) -> Result<()> {
|
||||
let mut acc = Default::default();
|
||||
|
||||
// First, look in the configuration.
|
||||
let config = sq.config_file.augment_with_policy(&sq.policy)?;
|
||||
let config = sq.config_file.effective_configuration(&sq)?;
|
||||
let r0 = Node::traverse(&*config.as_item() as _, &path)
|
||||
.map_err(Into::into)
|
||||
.and_then(
|
||||
|
@ -390,19 +390,20 @@ impl ConfigFile {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Augments the configuration with the given policy.
|
||||
/// Augments the configuration with the effective configuration
|
||||
/// and policy.
|
||||
///
|
||||
/// XXX: Due to the way doc.remove works, it will leave misleading
|
||||
/// comments behind. Therefore, the resulting configuration is
|
||||
/// not suitable for dumping, but may only be used for
|
||||
/// commands::config::get.
|
||||
pub fn augment_with_policy(&self, p: &StandardPolicy) -> Result<Self> {
|
||||
pub fn effective_configuration(&self, sq: &crate::Sq) -> Result<Self> {
|
||||
use std::io::Write;
|
||||
let mut raw = Vec::new();
|
||||
|
||||
// First, start with our configuration, and drop most of the
|
||||
// policy with the exception of the path.
|
||||
let p = ConfiguredStandardPolicy::from_policy(p.clone());
|
||||
let p = ConfiguredStandardPolicy::from_policy(sq.policy.clone());
|
||||
let mut doc = self.doc.clone();
|
||||
doc.remove("policy");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user