1
0
Fork 0

added the ablity to allow users the option of telling where the file they want to edit/update is

pull/1169/head
Joshua Estes 2012-10-03 08:23:56 -05:00
parent 2e34ada3f0
commit ebc67f3191
1 changed files with 10 additions and 2 deletions

View File

@ -41,6 +41,7 @@ class ConfigCommand extends Command
new InputOption('global', 'g', InputOption::VALUE_NONE, 'Set this as a global config settings.'),
new InputOption('editor', 'e', InputOption::VALUE_NONE, 'Open editor'),
new InputOption('list', 'l', InputOption::VALUE_NONE, 'List configuration settings'),
new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'If you want to choose a different composer.json or config.json'),
new InputArgument('setting-key', null, 'Setting key'),
new InputArgument('setting-value', InputArgument::IS_ARRAY, 'Setting value'),
))
@ -57,10 +58,17 @@ EOT
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
// Get the local composer.json or the global config.json
if ($input->getOption('global') && $input->getOption('file')) {
throw new \RuntimeException('Cannot use both, you must pick to edit either the global config or path to composer.json');
}
// Get the local composer.json, global config.json, or if the user
// passed in a file to use
$this->configFile = $input->getOption('global')
? (Factory::createConfig()->get('home') . '/config.json')
: 'composer.json';
: (null !== $input->getOption('file')
? $input->getOption('file')
: 'composer.json');
$this->configFile = new JsonFile($this->configFile);
if (!$this->configFile->exists()) {