made window mode accept shorter versions of mode name if they are unambiguous

This commit is contained in:
2023-01-20 23:51:24 +01:00
parent 0b4beba825
commit 5907651d10

View File

@ -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