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

Commit d7cd453

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 f91da40 commit d7cd453

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
@@ -53,9 +53,10 @@ def print_app_location(app_path):
5353
def cli_genanswers(args):
5454
try:
5555
argdict = args.__dict__
56+
location = argdict['answers']
5657
nm = NuleculeManager(app_spec=argdict['app_spec'],
5758
destination='none')
58-
nm.genanswers(**argdict)
59+
nm.genanswers(location=location, **argdict)
5960
Utils.rm_dir(nm.app_path) # clean up files
6061
sys.exit(0)
6162
except NuleculeException as e:
@@ -367,6 +368,11 @@ def create_parser(self):
367368
# === "genanswers" SUBPARSER ===
368369
gena_subparser = toplevel_subparsers.add_parser(
369370
"genanswers", parents=[globals_parser])
371+
gena_subparser.add_argument(
372+
"-a",
373+
"--answers",
374+
dest="answers",
375+
help="Path to %s" % ANSWERS_FILE)
370376
gena_subparser.add_argument(
371377
"app_spec",
372378
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)