Skip to content
This repository was archived by the owner on Jan 19, 2018. It is now read-only.

Commit 555c942

Browse files
committed
Adds -a option to genanswers to designate where to put answers.conf
Fixues issue: #588 Adds the feature to specify the destination of your answers.conf file generation.
1 parent 5e441c4 commit 555c942

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

atomicapp/cli/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ def print_app_location(app_path):
5252

5353
def cli_genanswers(args):
5454
argdict = args.__dict__
55+
location = argdict['answers']
5556
nm = NuleculeManager(app_spec=argdict['app_spec'],
5657
destination='none')
57-
nm.genanswers(**argdict)
58+
nm.genanswers(location=location, **argdict)
5859
Utils.rm_dir(nm.app_path) # clean up files
5960
sys.exit(0)
6061

@@ -350,6 +351,11 @@ def create_parser(self):
350351
# === "genanswers" SUBPARSER ===
351352
gena_subparser = toplevel_subparsers.add_parser(
352353
"genanswers", parents=[globals_parser])
354+
gena_subparser.add_argument(
355+
"-a",
356+
"--answers",
357+
dest="answers",
358+
help="Path to %s" % ANSWERS_FILE)
353359
gena_subparser.add_argument(
354360
"app_spec",
355361
nargs='?',

atomicapp/nulecule/main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def unpack(self, update=False,
131131
return Nulecule.load_from_path(
132132
self.app_path, dryrun=dryrun, config=config)
133133

134-
def genanswers(self, dryrun=False, answers_format=None, **kwargs):
134+
def genanswers(self, dryrun=False, answers_format=None, location=None, **kwargs):
135135
"""
136136
Renders artifacts and then generates an answer file. Finally
137137
copies answer file to the current working directory.
@@ -147,10 +147,14 @@ def genanswers(self, dryrun=False, answers_format=None, **kwargs):
147147
self.answers_format = answers_format or ANSWERS_FILE_SAMPLE_FORMAT
148148

149149
# Check to make sure an answers.conf file doesn't exist already
150-
answers_file = os.path.join(os.getcwd(), ANSWERS_FILE)
150+
if location is None:
151+
answers_file = os.path.join(os.getcwd(), ANSWERS_FILE)
152+
else:
153+
answers_file = os.path.join(location, ANSWERS_FILE)
154+
151155
if os.path.exists(answers_file):
152156
raise NuleculeException(
153-
"Can't generate answers.conf over existing file")
157+
"Can't generate %s over existing file" % answers_file)
154158

155159
# Call unpack to get the app code
156160
self.nulecule = self.unpack(update=False, dryrun=dryrun, config=self.answers)

0 commit comments

Comments
 (0)