add mode switch to cfg script
This commit is contained in:
parent
50cc1130e2
commit
097ca9444f
2 changed files with 26 additions and 13 deletions
25
bin/cfg
25
bin/cfg
|
|
@ -22,7 +22,7 @@ foreach ($autoloadFiles as $autoloadFile) {
|
|||
}
|
||||
}
|
||||
|
||||
$version = '0.1 beta';
|
||||
$version = '0.2';
|
||||
|
||||
$actions = [ 'show', 'write', 'help' ];
|
||||
$settings = ['key' => '', 'value' => ''];
|
||||
|
|
@ -45,6 +45,11 @@ $collection = (new Input\InputCollection())
|
|||
->description('Path to a json file to to write to')
|
||||
) // }}}
|
||||
|
||||
->add( Input\InputTypeFactory::build('LongOption')->name('mode')->short('m') // {{{
|
||||
->flags(AbstractInputType::FLAG_OPTIONAL | Input\AbstractInputType::FLAG_VALUE_REQUIRED)
|
||||
->description('Set a mode')
|
||||
) // }}}
|
||||
|
||||
->add( Input\InputTypeFactory::build('LongOption')->name('appPath')->short('a') // {{{
|
||||
->flags(AbstractInputType::FLAG_OPTIONAL | Input\AbstractInputType::FLAG_VALUE_REQUIRED)
|
||||
->description('Path where the config/ directory for the conf files is located, defaults to the working dir')
|
||||
|
|
@ -185,14 +190,20 @@ foreach(new RecursiveIteratorIterator($it) as $file)
|
|||
}
|
||||
}
|
||||
*/
|
||||
$cfg = (new Settings())->appPath($appPath)->prefix($prefix);
|
||||
$mode = ($argv->find('mode') == '') ? null : $argv->find('mode');
|
||||
$cfg = (new Settings([], $mode))->appPath($appPath)->prefix($prefix);
|
||||
if ($pkgPath = $argv->find('pkgPath')) $cfg->pkgPath($pkgPath);
|
||||
|
||||
if (is_readable($cfg->buildFileName('default'))) {
|
||||
$cfg->load();
|
||||
}
|
||||
elseif (is_readable($cfgFile = $cfg->buildFileName())) {
|
||||
$cfg->load(require($cfgFile));
|
||||
try {
|
||||
if (is_readable($cfg->buildFileName('default'))) {
|
||||
$cfg->load();
|
||||
}
|
||||
elseif (is_readable($cfgFile = $cfg->buildFileName())) {
|
||||
$cfg->load(require($cfgFile));
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo "Error: ".$e->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
//var_dump($cfg);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue