Browse Source

dynamic stack command depend on config

feature/refactor-php
harshadyeola 9 years ago
parent
commit
380cebe9df
  1. 14
      php/EE_CLI/Configurator.php
  2. 10
      php/EE_CLI/Runner.php

14
php/EE_CLI/Configurator.php

@ -169,6 +169,19 @@ class Configurator {
}
}
/**
* Check if stack exists in YAML file.
*
* @param string $yml_file Path to the YAML file
* @return boolean if stack exists
**/
public function check_stack_exists($path, $stack){
if (array_key_exists($stack, self::load_yml( $path ))){
return true;
}
return false;
}
/**
* Load values from a YAML file.
*
@ -220,4 +233,5 @@ class Configurator {
}
}
}

10
php/EE_CLI/Runner.php

@ -259,8 +259,9 @@ class Runner {
/*
Dynamic arguments for stack to be checked before parsing
*/
private static function stack_work($args, $assoc_args)
private function stack_work($args, $assoc_args)
{
$configurator = \EE_CLI::get_configurator();
print_r($args);
print_r($assoc_args);
foreach ( $assoc_args as $key => $value) {
@ -268,7 +269,12 @@ class Runner {
if ($args[1] === 'install'){
// check if key matches any stack config
// otherwise throw error if not exists
unset( $assoc_args[ $key ] );
if($configurator->check_stack_exists($this->global_config_path, $key)){
unset( $assoc_args[ $key ] );
}
else {
print("Error:");
}
}
}
}

Loading…
Cancel
Save