diff options
author | Jordan <me@jordan.im> | 2022-09-10 13:23:24 -0700 |
---|---|---|
committer | Jordan <me@jordan.im> | 2022-09-10 13:23:24 -0700 |
commit | a056d260e339bc6a5a83d5444d0ae3390d3df0e9 (patch) | |
tree | e75f3b1ac820dfd886dfcb6fa09d3a98726d4e49 | |
parent | 9f7cecdb131f7295e315bc9ea6c829025b773188 (diff) | |
download | asn-a056d260e339bc6a5a83d5444d0ae3390d3df0e9.tar.gz asn-a056d260e339bc6a5a83d5444d0ae3390d3df0e9.zip |
asn: mutualize runtime parameters
-rwxr-xr-x | asn.py | 28 |
1 files changed, 19 insertions, 9 deletions
@@ -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) + |