Skip to content

Commit

Permalink
make loading of additional config files optional
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Jun 24, 2021
1 parent b9623d7 commit 7b84a34
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 25 deletions.
38 changes: 20 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<description><![CDATA[Push update support for desktop app.
Once the app is installed, the push binary needs to be setup. You can either use the setup wizard with `occ notify_push:setup` or see the [README](http://github.com/nextcloud/notify_push) for detailed setup instructions]]></description>
<version>0.2.0</version>
<version>0.2.1</version>
<licence>agpl</licence>
<author>Robin Appelman</author>
<namespace>NotifyPush</namespace>
Expand Down
9 changes: 6 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ pub struct Opt {
/// Disable ansi escape sequences in logging output
#[structopt(long)]
pub no_ansi: bool,
/// Load other files named *.config.php in the config folder
#[structopt(long)]
pub glob_config: bool,
}

#[derive(Debug)]
Expand Down Expand Up @@ -171,7 +174,7 @@ impl Config {
let from_config = opt
.config_file
.as_ref()
.map(PartialConfig::from_file)
.map(|path| PartialConfig::from_file(path, opt.glob_config))
.transpose()?
.unwrap_or_default();
let from_env = PartialConfig::from_env()?;
Expand Down Expand Up @@ -232,8 +235,8 @@ impl PartialConfig {
})
}

fn from_file(file: impl AsRef<Path>) -> Result<Self> {
parse_config_file(file)
fn from_file(file: impl AsRef<Path>, glob: bool) -> Result<Self> {
parse_config_file(file, glob)
}

fn from_opt(opt: Opt) -> Self {
Expand Down
7 changes: 4 additions & 3 deletions src/config/nc.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::config::PartialConfig;
use color_eyre::{eyre::WrapErr, Result};
use nextcloud_config_parser::parse;
use nextcloud_config_parser::{parse, parse_glob};
use std::path::Path;

pub(super) fn parse_config_file(path: impl AsRef<Path>) -> Result<PartialConfig> {
let config = parse(path).wrap_err("Failed to parse nextcloud config")?;
pub(super) fn parse_config_file(path: impl AsRef<Path>, glob: bool) -> Result<PartialConfig> {
let config = if glob { parse(path) } else { parse_glob(path) }
.wrap_err("Failed to parse nextcloud config")?;

Ok(PartialConfig {
database: Some(config.database.into()),
Expand Down

0 comments on commit 7b84a34

Please sign in to comment.