Verified Commit 3f82c44b authored by anarcat's avatar anarcat
Browse files

allow passing location through the environment correctly

We need an extra control after argument passing to make sure it's
there when the options are not given though.
parent 72e79e84
......@@ -84,14 +84,12 @@ class BatchArgParser(argparse.ArgumentParser):
self.add_argument(
"-l",
"--location",
required=True,
help="WebDAV URI, default: %(default)s, from WEBDAV_LOCATION environment",
default=os.environ.get("WEBDAV_LOCATION"),
)
self.add_argument(
"-u",
"--username",
required=True,
help="WebDAV username, default: %(default)s, from WEBDAV_USERNAME environment",
default=os.environ.get("WEBDAV_USERNAME"),
)
......@@ -106,6 +104,9 @@ class BatchArgParser(argparse.ArgumentParser):
args = super().parse_args(*args, **kwargs)
if args.password is None:
args.password = input("Password:")
for attr in ('location', 'username', 'password'):
if not getattr(args, attr):
self.error("no %s provided, provide one with --%s or WEBDAV_%s environment" % (attr, attr, attr.upper()))
return args
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment