From a056d260e339bc6a5a83d5444d0ae3390d3df0e9 Mon Sep 17 00:00:00 2001 From: Jordan Date: Sat, 10 Sep 2022 13:23:24 -0700 Subject: asn: mutualize runtime parameters --- asn.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/asn.py b/asn.py index 0eb8c6c..e59563e 100755 --- a/asn.py +++ b/asn.py @@ -268,17 +268,27 @@ if __name__ == '__main__': args = parser.parse_args() db = DB() - if args.host and args.port: - listen = Listener(db, args.host, args.port) - elif args.update: + if not len(sys.argv) > 1: + parser.print_help(sys.stderr) + sys.exit() + + if args.populate and args.update: + log.error('--populate and --update used; redundant, use one') + sys.exit() + + if args.populate: + log.info('creating and populating db cache...') + db.populate_db() + + if args.update: log.info('checking remote repository for new dataset...') if db.update(): - log.info('dataset updated, creating/populating cache...') + log.info('dataset fetched and updated') db.populate_db() else: log.info('no changes since last update') - elif args.populate: - log.info('creating/populating cache...') - db.populate_db() - else: - parser.print_help(sys.stderr) + + if args.host and args.port: + log.info(f'listening on {args.host}:{args.port}') + listen = Listener(db, args.host, args.port) + -- cgit v1.2.3-54-g00ecf