Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: allow loading subscriptions from an empty directory #237

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ async fn main() {
.arg(arg!(<path> "Directory of configuration files or a single configuration file"))
.arg(arg!(-k --keep "Do not delete subscriptions that are not present in the configuration"))
.arg(arg!(-y --yes "Do not prompt for confirmation when <path> is a configuration file and --keep is not used"))
.arg(arg!(-e --"allow-empty" "Allow loading from empty directories"))
.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."))
)
.subcommand(
Expand Down
3 changes: 2 additions & 1 deletion cli/src/subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ async fn load(db: &Db, matches: &ArgMatches) -> Result<()> {
.ok_or_else(|| anyhow!("Missing argument path"))?;
let keep = matches.get_one::<bool>("keep").expect("Defaulted by clap");
let yes = matches.get_one::<bool>("yes").expect("Defaulted by clap");
let allow_empty = matches.get_one::<bool>("allow-empty").expect("Defaulted by clap");
let revision = matches.get_one::<String>("revision");

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

if subscriptions.is_empty() {
if subscriptions.is_empty() && !allow_empty {
bail!("Could not find any subscriptions");
}

Expand Down