equal
deleted
inserted
replaced
63 |
63 |
64 impl Config { |
64 impl Config { |
65 /// Load system and user configuration from various files. |
65 /// Load system and user configuration from various files. |
66 /// |
66 /// |
67 /// This is also affected by some environment variables. |
67 /// This is also affected by some environment variables. |
68 /// |
68 pub fn load( |
69 /// TODO: add a parameter for `--config` CLI arguments |
69 cli_config_args: impl IntoIterator<Item = impl AsRef<[u8]>>, |
70 pub fn load() -> Result<Self, ConfigError> { |
70 ) -> Result<Self, ConfigError> { |
71 let mut config = Self { layers: Vec::new() }; |
71 let mut config = Self { layers: Vec::new() }; |
72 let opt_rc_path = env::var_os("HGRCPATH"); |
72 let opt_rc_path = env::var_os("HGRCPATH"); |
73 // HGRCPATH replaces system config |
73 // HGRCPATH replaces system config |
74 if opt_rc_path.is_none() { |
74 if opt_rc_path.is_none() { |
75 config.add_system_config()? |
75 config.add_system_config()? |
89 } else { |
89 } else { |
90 config.add_trusted_file(&path)? |
90 config.add_trusted_file(&path)? |
91 } |
91 } |
92 } |
92 } |
93 } |
93 } |
|
94 } |
|
95 if let Some(layer) = ConfigLayer::parse_cli_args(cli_config_args)? { |
|
96 config.layers.push(layer) |
94 } |
97 } |
95 Ok(config) |
98 Ok(config) |
96 } |
99 } |
97 |
100 |
98 fn add_trusted_dir(&mut self, path: &Path) -> Result<(), ConfigError> { |
101 fn add_trusted_dir(&mut self, path: &Path) -> Result<(), ConfigError> { |