From ebc67f31910262040d594564f650c53a2549ab13 Mon Sep 17 00:00:00 2001 From: Joshua Estes Date: Wed, 3 Oct 2012 08:23:56 -0500 Subject: [PATCH] added the ablity to allow users the option of telling where the file they want to edit/update is --- src/Composer/Command/ConfigCommand.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 5c82040f4..cc05cd945 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -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()) {