/**
  * {@inheritdoc}
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     // TODO: Ensure that configurations have been initialized
     // Get available config sets
     $helper = new ConfigHelper();
     $configsets = $helper->getAllConfigSets();
     $homedir = getenv('HOME');
     // Check if passed argument is 'all'
     $names = $input->getArgument('setting');
     if (empty($names)) {
         // If no argument passed, prompt the user for which config set to display
         $qhelper = $this->getHelper('question');
         $message = "<question>Choose the number corresponding to which configuration set(s) to display:</question> ";
         $output->writeln($message);
         $message = "<comment>Separate multiple values with commas.</comment>";
         $options = array_merge(array_keys($configsets), array('current', 'all'));
         $question = new ChoiceQuestion($message, $options, 0);
         $question->setMultiselect(TRUE);
         $names = $qhelper->ask($input, $output, $question);
     }
     if (in_array('all', $names)) {
         $names = array_keys($configsets);
     }
     // Is passed config set valid?
     foreach ($names as $key => $name) {
         if ($name == 'current') {
             $env_vars = $helper->getCurrentEnvVars();
             $output->writeln("<info>---------------- Start config set: <options=bold>CURRENT DCI ENVIRONMENT</options=bold></info> ----------------</info>");
             $output->writeln("<comment;options=bold>Defined in ~/.drupalci/config:</comment;options=bold>");
             $contents = $helper->getCurrentConfigSetContents();
             foreach ($contents as $line) {
                 $parsed = explode("=", $line);
                 if (!empty($parsed[0]) && !empty($parsed[1])) {
                     $output->writeln("<comment>" . strtoupper($parsed[0]) . ": </comment><info>" . $parsed[1] . "</info>");
                 }
             }
             if (!empty($env_vars)) {
                 $output->writeln("<comment;options=bold>Defined in Environment Variables:</comment;options=bold>");
                 foreach ($env_vars as $key => $value) {
                     $output->writeln("<comment>" . strtoupper($key) . ": </comment><info>" . $value . "</info>");
                 }
                 $output->writeln("<info>------------ End config set: <options=bold>CURRENT DCI ENVIRONMENT</options=bold></info> ----------------</info>");
                 $output->writeln('');
             }
         } elseif (in_array($name, array_keys($configsets))) {
             $contents = file_get_contents($configsets[$name]);
             $output->writeln("<info>---------------- Start config set: <options=bold>{$name}</options=bold></info> ----------------</info>");
             $output->writeln($contents);
             $output->writeln("<info>------------ End config set: <options=bold>{$name}</options=bold></info> ----------------</info>");
             $output->writeln('');
         } else {
             $output->writeln("<error>Configuration set '{$name}' not found.  Skipping.</error>");
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function run(JobInterface $job, $data = NULL)
 {
     // Get and parse test definitions
     // DrupalCI jobs are controlled via a hierarchy of configuration settings, which define the behaviour of the platform while running DrupalCI jobs.  This hierarchy is defined as follows, which each level overriding the previous:
     // 1. Out-of-the-box DrupalCI defaults
     // 2. Local overrides defined in ~/.drupalci/config
     // 3. 'DCI_' namespaced environment variable overrides
     // 4. Test-specific overrides passed inside a DrupalCI test definition (e.g. .drupalci.yml)
     // 5. Custom overrides located inside a test definition defined via the $source variable when calling this function.
     $confighelper = new ConfigHelper();
     // Load job defaults
     $platform_args = $job->getPlatformDefaults();
     $default_args = $job->getDefaultArguments();
     if (!empty($default_args)) {
         $job->getOutput()->writeln("<comment>Loading build variables for this job type.</comment>");
     }
     // Load DrupalCI local config overrides
     $local_args = $confighelper->getCurrentConfigSetParsed();
     if (!empty($local_args)) {
         $job->getOutput()->writeln("<comment>Loading build variables from DrupalCI local config overrides.</comment>");
     }
     // Load "DCI_ namespaced" environment variable overrides
     $environment_args = $confighelper->getCurrentEnvVars();
     if (!empty($environment_args)) {
         $job->getOutput()->writeln("<comment>Loading build variables from namespaced environment variable overrides.</comment>");
     }
     // Load command line arguments
     // TODO: Routine for loading command line arguments.
     // TODO: How do we pull arguments off the drupalci command, when in a job class?
     // $cli_args = $somehelper->loadCLIargs();
     $cli_args = array();
     if (!empty($cli_args)) {
         $job->getOutput()->writeln("<comment>Loading test parameters from command line arguments.</comment>");
     }
     // Create temporary config array to use in determining the definition file source
     $config = $cli_args + $environment_args + $local_args + $default_args + $platform_args;
     // Load any build vars defined in the job definition file
     // Retrieve test definition file
     if (isset($source)) {
         $config['explicit_source'] = $source;
     }
     $definition_file = $this->getDefinitionFile($config);
     $definition_args = array();
     // Load test definition file
     if (!empty($definition_file)) {
         $job->getOutput()->writeln("<comment>Loading test parameters from build file: </comment><info>{$definition_file}</info>");
         $jobdef = new JobDefinition();
         $result = $jobdef->load($definition_file);
         if ($result == -1) {
             // Error loading definition file.
             $job->errorOutput("Failed", "Unable to parse build file.");
             // TODO: Robust error handling
             return;
         }
         $job_definition = $jobdef->getParameters();
         if (empty($job_definition)) {
             $job_definition = array();
             $definition_args = array();
         } else {
             $definition_args = !empty($job_definition['build_vars']) ? $job_definition['build_vars'] : array();
         }
         $job->setDefinition($job_definition);
     }
     $config = $cli_args + $definition_args + $environment_args + $local_args + $default_args + $platform_args;
     // Set initial build variables
     $buildvars = $job->getBuildVars();
     $job->setBuildVars($buildvars + $config);
     // Map relevant build variables into the job definition array
     // $this->buildvarsToDefinition($job);
     return;
 }