Skip to content

Commit 02de204

Browse files
author
George K. Thiruvathukal
committed
updates for id handling & output of document
1 parent fa46a3b commit 02de204

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

zettelgeist/zettel.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def get_argparse():
256256
parser.add_argument('--digits', type=int, help="digits in counter (default=4)", default=4)
257257

258258
parser.add_argument('--separator', type=str, help="separate components with delimiter (default is '-')", default="-")
259-
parser.add_argument('--counter', type=str, help="counter name")
259+
parser.add_argument('--counter', type=str, help="counter name (defaults to --id if present) ")
260260
parser.add_argument('--counter-path', type=str, help="counter filename/path to filename", default=".counter.dat")
261261

262262
parser.add_argument('--restrict-output-fields',
@@ -569,8 +569,16 @@ def main():
569569
if args.id != None:
570570
name_components['id'] = args.id
571571
digits = args.digits
572-
if args.counter != None:
573-
seq = get_count(args.counter_path, args.counter)
572+
573+
# --counter and --id can be specified separately
574+
# If omitted, --counter takes on --id
575+
# If both are omitted, then we are not using counters in the generated names.
576+
counter_name = args.counter
577+
if not args.counter:
578+
counter_name = args.id
579+
580+
if counter_name != None:
581+
seq = get_count(args.counter_path, counter_name)
574582
seq_text = str(seq)
575583
digits = max(len(seq_text), digits)
576584
pad_text = "0" * (digits - len(seq_text))

0 commit comments

Comments
 (0)