Skip to content

Commit d29cb66

Browse files
committed
fix(gui): properly handle -ez True/False from notebook args
Root cause: argparse short flags must be single letter (-e), but '-ez' is 2 chars. argparse parsed '-e' as the flag and 'z' as its value, then the next token (True/False) became an unrecognized argument. Notebook calls: python gui.py --share -ez $ez (where $ez=True/False) Fix: Pre-normalize sys.argv before argparse runs: - '-ez True' / '--ez true' -> '--easy true' - '-ez False' / '--ez false' -> stripped (easy stays disabled) - 'ez' / 'easygui' (positional) -> '--easy true' - '--easy' now uses type=str with parse_known_args() for compat with both --easy (store_true) and --easy true (value) patterns
1 parent 5be4d3e commit d29cb66

1 file changed

Lines changed: 32 additions & 5 deletions

File tree

  • advanced_rvc_inference/app

advanced_rvc_inference/app/gui.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,35 @@ def create_app():
335335
if __name__ == "__main__":
336336
import argparse
337337

338-
# Handle shorthand launch args (ez, easygui -> --easy)
339-
if len(sys.argv) > 1 and sys.argv[1].lower() in ("ez", "easygui"):
340-
sys.argv[1] = "--easy"
338+
# Normalize shorthand args before argparse sees them.
339+
# The notebook / CLI uses "-ez True" or "-ez False" which is invalid for
340+
# argparse (short flags must be a single letter). Rewrite them to
341+
# "--easy true" / "--easy false" (or drop entirely when false).
342+
_normalized = []
343+
skip_next = False
344+
for i, arg in enumerate(sys.argv):
345+
if skip_next:
346+
skip_next = False
347+
continue
348+
if arg.lower() in ("-ez", "--ez"):
349+
if i + 1 < len(sys.argv) and not sys.argv[i + 1].startswith("-"):
350+
val = sys.argv[i + 1].lower()
351+
if val in ("true", "1", "yes"):
352+
_normalized.append("--easy")
353+
_normalized.append("true")
354+
# false-ish -> omit entirely (easy stays disabled)
355+
skip_next = True
356+
else:
357+
# No value after -ez -> default to true
358+
_normalized.append("--easy")
359+
_normalized.append("true")
360+
continue
361+
if arg.lower() in ("ez", "easygui"):
362+
_normalized.append("--easy")
363+
_normalized.append("true")
364+
continue
365+
_normalized.append(arg)
366+
sys.argv = _normalized
341367

342368
parser = argparse.ArgumentParser(description="Launch Advanced RVC Inference GUI")
343369
parser.add_argument("--host", default="0.0.0.0", help="Host to bind to")
@@ -346,9 +372,10 @@ def create_app():
346372
parser.add_argument("--no-share", action="store_true", help="Disable public URL, use local access only")
347373
parser.add_argument("--open", action="store_true", help="Open in browser")
348374
parser.add_argument("--keep-alive", action="store_true", default=True, help="Keep tunnel alive (default: True)")
349-
parser.add_argument("--easy", action="store_true", help="Launch Easy GUI (simplified mode)")
375+
parser.add_argument("--easy", type=str, default=None, help="Launch Easy GUI (simplified mode). Use 'true' to enable.")
350376

351377
args, _unknown = parser.parse_known_args()
378+
easy_mode = args.easy is not None and args.easy.lower() in ("true", "1", "yes")
352379

353380
sys.exit(
354381
launch(
@@ -357,6 +384,6 @@ def create_app():
357384
server_port=args.port,
358385
inbrowser=args.open,
359386
keep_alive=args.keep_alive,
360-
easy=args.easy,
387+
easy=easy_mode,
361388
)
362389
)

0 commit comments

Comments
 (0)