Adds -a option to genanswers to designate where to put answers.conf
Fixues issue: https://github.com/projectatomic/atomicapp/issues/588
Adds the feature to specify the destination of your answers.conf file generation.
#dotests
openshift tests = false positive? the timeout issue occured
Tests pass locally :+1:
The reason to use -a is symmetry:
genanswers -a demo/answers.conf Nulecule/
atomicapp run -a demo/answers.conf Nulecule/
I understand the arguments for other parameters, but I don't find them persuasive. Anything other than -a is going to require me to look it up.
I understand the arguments for other parameters, but I don't find them persuasive. Anything other than -a is going to require me to look it up.
This is partly why I decided to have the only behavior to be to put the file in your cwd. If it has one behavior then it is certainly easy to remember. :-P
Except that using the CWD is asymmetrical. That is, "run" requires -a if you want to use an answers.conf, it won't use CWD.
@dustymabe Should we change this to --destination or stick to -a ? What's your opinion?
@cdrage here's the instructions I want to be able to give:
- generate answers with
atomicapp genanswers -a answers.conf Nulecule/ - edit answers
- run the app
atomicapp run -a answers.conf Nulecule/
See the advantage in usability from being symmetric with the use of the -a parameter? The user doesn't have to constantly look up which switch is usable with which command. -a always means answers.conf.
Relevant to this, the PostgreSQL project used to have different parameters for different commands when it came to databases and the data directory. After years of user bug reports, we refactored and made them consistent; all CLI commands use -D for the data directory and -d for the database, or they don't support those parameters. And the letter 'd' is used for nothing else.
Let's start out by being consistent instead of having to refactor later.
@cdrage -a is fine.
generate answers with atomicapp genanswers -a answers.conf Nulecule/
@jberkus just so we are clear, my understanding is that command will create an answers.conf file in your current directory. Is that your understanding?
if a directory is not supplied, yes. but if you do this:
atomicapp genanswers -a Nulecule/dev/answers.conf Nulecule/
... then it would create it in Nulecule/dev/ relative to the current directory. Or any other user-supplied directory. Just to keep things simple, if the directory does not exist, it should error.
#dotests
@jberkus @dustymabe
Updated this PR to include checking if the directory exists + rebased against master
Ok a few comments in the code. We also need to decide exactly "what" happens when. Let's create a few cases:
- User provides path to existing directory
- aa genanswers -a /path/to/dir
- => creates /path/to/dir/answers.conf
- User provides path to a file (not existing) in an existing directory
- aa genanswers -a /path/to/dir/somefile
- => creates /path/to/dir/somefile
- User provides path to a directory that does not exist
- aa genanswers -a /path/to/no/dir
- => error - directory does not exist
The hard part about this is number 2. How do we know if the user provided the path to a file that they wanted us to create or they provided us a path to a directory that doesn't exist?
I think we should just make them give us a full file name when providing -a. That way it is simple:
if dirname(file) doesn't exist => error if file exists => error else create file
Will continue on this once #658 is merged so we can use the "are we in a container" util
Will continue on this once #658 is merged so we can use the "are we in a container" util
No need to wait as we already have the Utils.inContainer() function.
Update: I'm going to pick back up on this soon. ^^