From 7e1ab641981c48db7b9b6c4545a23945c0370558 Mon Sep 17 00:00:00 2001 From: Ian Cornelius Date: Sat, 24 Aug 2024 21:59:14 -0500 Subject: [PATCH] Fix #42: inherit `counter` from `id` by default --- zettelgeist/zettel.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/zettelgeist/zettel.py b/zettelgeist/zettel.py index fec1d87..0e300fb 100644 --- a/zettelgeist/zettel.py +++ b/zettelgeist/zettel.py @@ -557,6 +557,9 @@ def main(): if not os.path.exists(name_dir): print("Destination directory specified (--name-dir %s) does not exist. Will not write file.") sys.exit(1) + # If omitted, --counter takes on --id + if args.id and not args.counter: + argsd['counter'] = args.id for arg in args.name: if arg not in ['id','timestamp', 'counter']: print("--name may only use id, counter, and timestamp (%s found)" % arg) @@ -569,11 +572,10 @@ def main(): name_components['id'] = args.id digits = args.digits - # --counter and --id can be specified separately # If omitted, --counter takes on --id - # If both are omitted, then we are not using counters in the generated names. - counter_name = args.counter - if not args.counter: + if args.counter: + counter_name = args.counter + elif args.id: counter_name = args.id if counter_name != None: