From 4b6bb4e4181b4d65073843caca6bf1f3b29ce7b2 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 27 Jun 2019 14:06:47 +0200 Subject: [PATCH] Cleanup some command line option oddities Signed-off-by: Clifford Wolf --- sbysrc/sby.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sbysrc/sby.py b/sbysrc/sby.py index 53212d7..e64433d 100644 --- a/sbysrc/sby.py +++ b/sbysrc/sby.py @@ -33,16 +33,15 @@ parser = argparse.ArgumentParser(prog="sby", parser.set_defaults(exe_paths=dict()) parser.add_argument("-d", metavar="", dest="workdir", - help="set workdir name (ignored if is given as a positional argument). default: (without .sby)") + help="set workdir name. default: or _") parser.add_argument("-f", action="store_true", dest="force", help="remove workdir if it already exists") parser.add_argument("-b", action="store_true", dest="backup", help="backup workdir if it already exists") parser.add_argument("-t", action="store_true", dest="tmpdir", help="run in a temporary workdir (remove when finished)") -parser.add_argument("-T", metavar="", action="append", dest="tasknames", - default=list(), - help="add taskname (useful when sby file is read from stdin, ignored if tasknames are given as positional arguments)") +parser.add_argument("-T", metavar="", action="append", dest="tasknames", default=list(), + help="add taskname (useful when sby file is read from stdin)") parser.add_argument("-E", action="store_true", dest="throw_err", help="throw an exception (incl stack trace) for most errors") @@ -71,15 +70,15 @@ parser.add_argument("--setup", action="store_true", dest="setupmode", help="set up the working directory and exit") parser.add_argument("sbyfile", metavar=".sby | ", nargs="?", - help=".sby file OR directory containing config.sby file (causes -d to be ignored if is used)") + help=".sby file OR directory containing config.sby file") parser.add_argument("arg_tasknames", metavar="tasknames", nargs="*", - help="tasks to run (only valid when is used, causes -T to be ignored)") + help="tasks to run (only valid when .sby is used)") args = parser.parse_args() sbyfile = args.sbyfile workdir = args.workdir -tasknames = args.arg_tasknames if args.arg_tasknames else args.tasknames +tasknames = args.arg_tasknames + args.tasknames opt_force = args.force opt_backup = args.backup opt_tmpdir = args.tmpdir @@ -93,6 +92,9 @@ setupmode = args.setupmode if sbyfile is not None: if os.path.isdir(sbyfile): + if workdir is not None: + print("ERROR: Can't use -d when running in existing directory.", file=sys.stderr) + sys.exit(1) workdir = sbyfile sbyfile += "/config.sby" reusedir = True -- 2.30.2