From d3895cd43d75ea97efc30e5b5b131ae6aa7d3d39 Mon Sep 17 00:00:00 2001 From: redxef Date: Thu, 13 Oct 2022 00:53:28 +0200 Subject: [PATCH] Add dryrun flag. --- main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index ba7d260..cb987f7 100755 --- a/main.py +++ b/main.py @@ -114,7 +114,8 @@ def init_logging(level: str): @click.command() @click.option('--level', '-l', envvar='WP_CAL_LEVEL', default=':WARNING,wp_cal:INFO', help='The log level for the application') @click.option('--config', '-c', envvar='WP_CAL_CONFIG', default='-', help='The configuration file') -def main(level, config): +@click.option('--dryrun', '-d', envvar='WP_CAL_DRYRUN', is_flag=True, help="Don't actually post any data, just show it") +def main(level, config, dryrun): logging.basicConfig() init_logging(level) @@ -149,7 +150,10 @@ def main(level, config): events = g.get_events() logger.info("syncing %d events", len(events)) w.login() - w.post_events(events) + if dryrun: + logger.info("dryrun; would post events: %s", events) + else: + w.post_events(events) logger.info("done") if __name__ == '__main__':