Navigation Menu

Skip to content

Commit

Permalink
fixed saving to jsone file and using from jsone file the export param…
Browse files Browse the repository at this point in the history
…eter
  • Loading branch information
sdenev committed Oct 8, 2012
1 parent 45d12f5 commit 1a28b9f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cli/export.php
Expand Up @@ -184,10 +184,6 @@ function main($filename, $dir, $params, $options)
if ('default' === $params[CMD_PARAM_EXPORT] && $formatters = array_keys($bootstrap->getFormatters())) { if ('default' === $params[CMD_PARAM_EXPORT] && $formatters = array_keys($bootstrap->getFormatters())) {
$params[CMD_PARAM_EXPORT] = $formatters[0]; $params[CMD_PARAM_EXPORT] = $formatters[0];
} }
if (!$formatter = $bootstrap->getFormatter($params[CMD_PARAM_EXPORT])) {
echo sprintf("Unsupported exporter %s. Use --%s option to show all available exporter.", $params[CMD_PARAM_EXPORT], CMD_OPT_LIST_EXPORTER);
die(1);
}


// lookup config file export.json // lookup config file export.json
if (!$options[CMD_OPT_NO_AUTO_CONFIG] && !$params[CMD_PARAM_CONFIG]) { if (!$options[CMD_OPT_NO_AUTO_CONFIG] && !$params[CMD_PARAM_CONFIG]) {
Expand Down Expand Up @@ -222,6 +218,12 @@ function main($filename, $dir, $params, $options)
} }
} }


//get formatter after getting the parameter export either from command line or config file
if (!$formatter = $bootstrap->getFormatter($params[CMD_PARAM_EXPORT])) {
echo sprintf("Unsupported exporter %s. Use --%s option to show all available exporter.", $params[CMD_PARAM_EXPORT], CMD_OPT_LIST_EXPORTER);
die(1);
}

// parameters customization // parameters customization
echo sprintf("Exporting %s as %s.\n\n", basename($filename), $formatter->getTitle()); echo sprintf("Exporting %s as %s.\n\n", basename($filename), $formatter->getTitle());
$setup = $formatter->getConfigurations(); $setup = $formatter->getConfigurations();
Expand All @@ -237,7 +239,13 @@ function main($filename, $dir, $params, $options)


// save export parameters // save export parameters
if ($options[CMD_OPT_SAVE_CONFIG]) { if ($options[CMD_OPT_SAVE_CONFIG]) {
file_put_contents('export.json', json_encode(array(CMD_PARAM_EXPORT => $export, CMD_OPT_ZIP => $options[CMD_OPT_ZIP], 'dir' => $dir, 'params' => $setup))); file_put_contents('export.json', json_encode(
array(
CMD_PARAM_EXPORT => $params[CMD_PARAM_EXPORT],
CMD_OPT_ZIP => $options[CMD_OPT_ZIP],
'dir' => $dir, 'params' => $setup
)
));
} }


// start time // start time
Expand Down

0 comments on commit 1a28b9f

Please sign in to comment.