From bb0c0f7002c02c0d294253789c389a0d030d5936 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Mon, 1 Feb 2021 12:37:31 -0500 Subject: [PATCH] Add alphabetize option --- lightcards/lightcards.py | 13 +++++++++---- man/lightcards.1 | 3 +++ man/lightcards.1.md | 3 +++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lightcards/lightcards.py b/lightcards/lightcards.py index 768ac68..ed1916d 100644 --- a/lightcards/lightcards.py +++ b/lightcards/lightcards.py @@ -19,6 +19,9 @@ def parse_args(): metavar="input file", type=str, nargs=1) + parser.add_argument("-a", "--alphabetize", + action='store_true', + help="alphabetize card order") parser.add_argument("-f", "--flip", action='store_true', help="show second column first") @@ -60,14 +63,16 @@ def show(args, stack, headers): idx = Status() # Manipulate deck - if args.flip: - for x in stack: - x[0], x[1] = x[1], x[0] - headers[0], headers[1] = headers[1], headers[0] if args.shuffle: shuffle(stack) + if args.alphabetize: + stack.sort() if args.reverse: stack.reverse() + if args.flip: + for x in stack: + x[0], x[1] = x[1], x[0] + headers[0], headers[1] = headers[1], headers[0] # Send to display win = Display(stack, headers, idx) diff --git a/man/lightcards.1 b/man/lightcards.1 index 50ad3b0..06dd0c5 100644 --- a/man/lightcards.1 +++ b/man/lightcards.1 @@ -22,6 +22,9 @@ Relative or absolute path to the input Markdown or HTML file \f[B]-h\f[R], \f[B]\[en]help\f[R] Show a help message and exit .TP +\f[B]-a\f[R], \f[B]\[en]alphabetize\f[R] +Alphabetize card order +.TP \f[B]-f\f[R], \f[B]\[en]flip\f[R] Show second column first .TP diff --git a/man/lightcards.1.md b/man/lightcards.1.md index 275733d..adcb7e2 100644 --- a/man/lightcards.1.md +++ b/man/lightcards.1.md @@ -19,6 +19,9 @@ lightcards [[options]] [input file] **-h**, **--help** : Show a help message and exit +**-a**, **--alphabetize** +: Alphabetize card order + **-f**, **--flip** : Show second column first -- 2.39.2