Skip to content

Commit cc01205

Browse files
committed
Set single config value instead of multiple
Signed-off-by: Kirtan Gajjar <kirtangajjar95@gmail.com>
1 parent ea44142 commit cc01205

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

src/Config_Command.php

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
22

3-
use EE\Model\Site;
43
use Mustangostang\Spyc;
5-
use \Symfony\Component\Filesystem\Filesystem;
4+
use Symfony\Component\Filesystem\Filesystem;
65

76
/**
87
* Manges global EE configuration.
@@ -41,36 +40,31 @@ public function get( $args, $assoc_args ) {
4140
$config_file_path = getenv( 'EE_CONFIG_PATH' ) ? getenv( 'EE_CONFIG_PATH' ) : EE_CONF_ROOT . '/config.yml';
4241
$config = Spyc::YAMLLoad( $config_file_path );
4342

44-
if ( ! isset( $config[$args[0]] ) ) {
45-
EE::error("No config value with key '$args[0]' set");
43+
if ( ! isset( $config[ $args[0] ] ) ) {
44+
EE::error( "No config value with key '$args[0]' set" );
4645
}
4746

48-
EE::log( $config[$args[0]] );
47+
EE::log( $config[ $args[0] ] );
4948
}
5049

5150
/**
52-
* Get a config value
51+
* Set a config value
5352
*
5453
* ## OPTIONS
5554
*
56-
* <config-key-value>...
57-
* : Key value pair of config to set
55+
* <key>
56+
* : Key of config to set
57+
*
58+
* <value>
59+
* : Value of config to set
5860
*/
5961
public function set( $args, $assoc_args ) {
6062
$config_file_path = getenv( 'EE_CONFIG_PATH' ) ? getenv( 'EE_CONFIG_PATH' ) : EE_CONF_ROOT . '/config.yml';
6163
$config = Spyc::YAMLLoad( $config_file_path );
64+
$key = $args[0];
65+
$value = $args[1];
6266

63-
foreach ( $args as $arg ) {
64-
$key_val = explode( '=', $arg, 2 );
65-
66-
if ( count( $key_val ) < 2 ) {
67-
EE::warning( "Cannot add $arg in config as it has no corrosponding value" );
68-
continue;
69-
}
70-
71-
list( $key, $val ) = $key_val;
72-
$config[$key] = $value;
73-
}
67+
$config[ $key ] = $value;
7468

7569
$this->fs->dumpFile( $config_file_path, Spyc::YAMLDump( $config, false, false, true ) );
7670
}

0 commit comments

Comments
 (0)