made window mode accept shorter versions of mode name if they are unambiguous
This commit is contained in:
12
grum/cli.py
12
grum/cli.py
@ -27,9 +27,19 @@ def handle_clargs():
|
||||
|
||||
parser.add_argument("-e", "--examples", dest="add_examples", action="store_true", help="Add example data")
|
||||
|
||||
parser.add_argument("-w", "--window-mode", default="multi", choices=MDIWindowMode.values(), type=str.casefold, help="Set the initial window mode")
|
||||
parser.add_argument("-w", "--window-mode", default="multi", choices=MDIWindowMode.values(), type=unambiguous_window_mode, help="Set the initial window mode")
|
||||
|
||||
return parser.parse_args().__dict__
|
||||
|
||||
|
||||
|
||||
def unambiguous_window_mode(arg):
|
||||
cfarg = arg.casefold()
|
||||
values = MDIWindowMode.values()
|
||||
matches = [i for i in values if i.casefold().startswith(cfarg)]
|
||||
if len(matches) == 1:
|
||||
return matches[0]
|
||||
return arg
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user