Skip to content

Commit 263fff9

Browse files
authored
Merge pull request #237 from MrAnno/subscription-load-allow-empty
cli: allow loading subscriptions from an empty directory
2 parents 86db25a + e222343 commit 263fff9

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

cli/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ async fn main() {
254254
.arg(arg!(<path> "Directory of configuration files or a single configuration file"))
255255
.arg(arg!(-k --keep "Do not delete subscriptions that are not present in the configuration"))
256256
.arg(arg!(-y --yes "Do not prompt for confirmation when <path> is a configuration file and --keep is not used"))
257+
.arg(arg!(-e --"allow-empty" "Allow loading from empty directories"))
257258
.arg(arg!(-r --revision <REVISION> "Revision name of the configuration. If present, it will be added by openwec as metadata of all events received using this subscription."))
258259
)
259260
.subcommand(

cli/src/subscriptions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ async fn load(db: &Db, matches: &ArgMatches) -> Result<()> {
970970
.ok_or_else(|| anyhow!("Missing argument path"))?;
971971
let keep = matches.get_one::<bool>("keep").expect("Defaulted by clap");
972972
let yes = matches.get_one::<bool>("yes").expect("Defaulted by clap");
973+
let allow_empty = matches.get_one::<bool>("allow-empty").expect("Defaulted by clap");
973974
let revision = matches.get_one::<String>("revision");
974975

975976
let path_obj = Path::new(path);
@@ -985,7 +986,7 @@ async fn load(db: &Db, matches: &ArgMatches) -> Result<()> {
985986
let subscriptions =
986987
config::load_from_path(path, revision).context("Failed to load config files")?;
987988

988-
if subscriptions.is_empty() {
989+
if subscriptions.is_empty() && !allow_empty {
989990
bail!("Could not find any subscriptions");
990991
}
991992

0 commit comments

Comments
 (0)