Skip to content

Commit f72b990

Browse files
bryteisephmccarty
authored andcommitted
Require the target option to be passed
Similar to the URL, the common tooling always passes the target directive to autospec. Using this convention we can better initialize autospec state earlier and with less fallbacks.
1 parent 2c1a2bf commit f72b990

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

autospec/autospec.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def main():
177177
default="/usr/share/defaults/autospec/autospec.conf",
178178
help="Set configuration file to use")
179179
parser.add_argument("-t", "--target", dest="target", action="store",
180-
default=None,
180+
required=True,
181181
help="Target location to create or reuse")
182182
parser.add_argument("-i", "--integrity", action="store_true",
183183
default=False,
@@ -224,6 +224,13 @@ def main():
224224
license.add_license(infile_dict.get("LICENSE"))
225225
print_infile("License added: {}".format(infile_dict.get("LICENSE")))
226226

227+
if not args.target:
228+
parser.error(argparse.ArgumentTypeError(
229+
"The target option is not valid"))
230+
else:
231+
# target path must exist or be created
232+
os.makedirs(args.target, exist_ok=True)
233+
227234
if not url:
228235
parser.error(argparse.ArgumentTypeError(
229236
"the url argument or options.conf['package']['url'] is required"))

0 commit comments

Comments
 (0)