aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan <me@jordan.im>2022-09-10 13:23:24 -0700
committerJordan <me@jordan.im>2022-09-10 13:23:24 -0700
commita056d260e339bc6a5a83d5444d0ae3390d3df0e9 (patch)
treee75f3b1ac820dfd886dfcb6fa09d3a98726d4e49
parent9f7cecdb131f7295e315bc9ea6c829025b773188 (diff)
downloadasn-a056d260e339bc6a5a83d5444d0ae3390d3df0e9.tar.gz
asn-a056d260e339bc6a5a83d5444d0ae3390d3df0e9.zip
asn: mutualize runtime parameters
-rwxr-xr-xasn.py28
1 files 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)
+