From dc6c791fb09b9e5aab0eec970fdca707cd70dc47 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Fri, 12 Feb 2021 12:07:24 -0500 Subject: [PATCH] Add option to start in a specific view --- lightcards/display.py | 4 ++-- lightcards/runner.py | 11 ++++++++++- man/lightcards.1 | 17 ++++++++++------- man/lightcards.1.md | 17 ++++++++++------- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/lightcards/display.py b/lightcards/display.py index b167828..4739982 100644 --- a/lightcards/display.py +++ b/lightcards/display.py @@ -182,11 +182,11 @@ class Menu: class Display: - def __init__(self, stack, headers, obj): + def __init__(self, stack, headers, obj, view): self.stack = stack self.headers = headers self.obj = obj - self.view = 1 + self.view = view def run(self, stdscr): """Set important options that require stdscr before starting""" diff --git a/lightcards/runner.py b/lightcards/runner.py index a0c8a09..08004db 100644 --- a/lightcards/runner.py +++ b/lightcards/runner.py @@ -18,6 +18,15 @@ def parse_args(): parser = argparse.ArgumentParser( description="Terminal flashcards from Markdown" ) + parser.add_argument( + "-V", + "--view", + metavar="view", + type=int, + choices=range(1, 4), + default=1, + help="specify which view to start in (default = 1)", + ) parser.add_argument("inp", metavar="input file", type=str, nargs=1) parser.add_argument( "-a", @@ -70,7 +79,7 @@ def show(args, stack, headers): stack.reverse() # Send to display - win = Display(stack, headers, idx) + win = Display(stack, headers, idx, args.view) wrapper(win.run) diff --git a/man/lightcards.1 b/man/lightcards.1 index 6097ae2..47115f4 100644 --- a/man/lightcards.1 +++ b/man/lightcards.1 @@ -16,24 +16,27 @@ file\f[R], and displays flashcards from their contents. .SH OPTIONS .SS Generic Program Information .TP -\f[B]-h\f[R], \f[B]\[en]help\f[R] +\f[B]-h\f[R], \f[B]--help\f[R] Show a help message and exit .TP -\f[B]-v\f[R], \f[B]\[en]version\f[R] +\f[B]-v\f[R], \f[B]--version\f[R] Print version and exit -.SS Stack sorting +.SS Startup options .TP -\f[B]-a\f[R], \f[B]\[en]alphabetize\f[R] +\f[B]-a\f[R], \f[B]--alphabetize\f[R] Alphabetize card order .TP -\f[B]-p\f[R], \f[B]\[en]purge\f[R] +\f[B]-p\f[R], \f[B]--purge\f[R] Purge cache for chosen set .TP -\f[B]-r\f[R], \f[B]\[en]reverse\f[R] +\f[B]-r\f[R], \f[B]--reverse\f[R] Reverse card order .TP -\f[B]-s\f[R], \f[B]\[en]shuffle\f[R] +\f[B]-s\f[R], \f[B]--shuffle\f[R] Shuffle card order +.TP +\f[B]-V\f[R] [1-3], \f[B]--view\f[R] [1-3] +Specify startup view .SH KEYS .TP \f[B]l\f[R], \f[B]right\f[R] diff --git a/man/lightcards.1.md b/man/lightcards.1.md index 2cdd2b2..eb83e03 100644 --- a/man/lightcards.1.md +++ b/man/lightcards.1.md @@ -17,25 +17,28 @@ lightcards \[options\] \[input file\] # OPTIONS ## Generic Program Information -**-h**, **--help** +**-h**, **\--help** : Show a help message and exit -**-v**, **--version** +**-v**, **\--version** : Print version and exit -## Stack sorting -**-a**, **--alphabetize** +## Startup options +**-a**, **\--alphabetize** : Alphabetize card order -**-p**, **--purge** +**-p**, **\--purge** : Purge cache for chosen set -**-r**, **--reverse** +**-r**, **\--reverse** : Reverse card order -**-s**, **--shuffle** +**-s**, **\--shuffle** : Shuffle card order +**-V** \[1-3\], **\--view** \[1-3\] +: Specify startup view + # KEYS **l**, **right** : Next card -- 2.39.2