Skip to content

Commit

Permalink
Merge pull request #38 from mothership-gmbh/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
flyzard authored Sep 16, 2016
2 parents a9b3f6b + 81d2b84 commit decfd5d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ protected function configure()
InputOption::VALUE_REQUIRED,
'The name of the configuration'
);

$this->addOption(
'separator',
',',
InputOption::VALUE_REQUIRED,
'Csv Separator'
);
}

/**
Expand Down Expand Up @@ -78,7 +85,9 @@ protected function execute(
$input_interface = new \Mothership\Component\Feed\Input\InputMysqlData($this->getConnection());

$factory = new \Mothership\Magerun\Feed\FeedFactory($input_path . '/' . $filename, $input_interface);
$factory->processFeed(new OutputCsv($output_path . $filename . '.csv'));
$factory->processFeed(new OutputCsv($output_path . $filename . '.csv', $input->getOption('separator')));

// This is my changed code

$output->writeln('<comment>File saved to : ' . $output_path . $filename . '.csv' . '</comment>');
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ class RunCommand extends AbstractMagentoCommand
*/
protected function configure()
{
parent::configure();
parent::configure();

if (isset($GLOBALS['argv'][2])) {

$explodedConfig = explode("=", $GLOBALS['argv'][2]);
$workflowName = explode(".", $explodedConfig[1]);

$workflowName = isset($explodedConfig[1]) ? explode(".", $explodedConfig[1]) : '';
/**
* Add the option to add this to a queue. Requires a queue configuration
*/
Expand Down Expand Up @@ -143,7 +142,7 @@ protected function configure()
}

/**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*/
protected function interact(InputInterface $input, OutputInterface $output)
Expand Down Expand Up @@ -190,7 +189,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
/**
* The command
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @return int|void
Expand All @@ -200,15 +199,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
parent::execute($input, $output);

$input_path = $this->getApplication()->getMagentoRootFolder() . '/app/etc/mothership/workflows';
$filename = $this->detectConfiguration($input, $output, $input_path);
$filename = $this->detectConfiguration($input, $output, $input_path);

if ($input->hasOption('queue') && $input->getOption('queue')) {
/**
* Add the job for the incremental update
*/
$args = array_merge([
'workflow_path' => $this->getApplication()->getMagentoRootFolder() . '/app/etc/workflows/' . $input->getOption('config'),
'workflow' => $input->getOption('config'),
'workflow' => $input->getOption('config'),
], $this->getArguments($input, $output));

$this->printCommand($args, $output);
Expand Down Expand Up @@ -237,41 +236,45 @@ protected function printCommand($args, $output)
}

$ordered = array_merge(array_flip(array('config', 'environment', 'data_type', 'range', 'root-dir', 'queue')), $data);
$output->writeln("\n" . '<comment>magerun mothership:workflow:run --' . implode(' --', array_map(
function ($v, $k) { return $k . '=' . $v; },
$ordered,
array_keys($ordered)
)) . '</comment>');
$output->writeln("\n" . '<comment>magerun mothership:workflow:run --' . implode(' --', array_map(
function ($v, $k) {
return $k . '=' . $v;
},
$ordered,
array_keys($ordered)
)) . '</comment>');
}

/**
* Helper method to set the arguments for the state machine
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @return array
*/
protected function getArguments(
\Symfony\Component\Console\Input\InputInterface $input,
\Symfony\Component\Console\Output\OutputInterface $output
) {
)
{
return array_merge($input->getOptions(), [
'input' => $input,
'output' => $output,
'input' => $input,
'output' => $output,
'root-dir' => $this->getApplication()->getMagentoRootFolder(),
'yaml' => $this->parsedYaml
]) ;
'yaml' => $this->parsedYaml
]);
}

/**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param string $path
* @param string $path
*
* @return string
*/
protected function detectConfiguration(InputInterface $input, OutputInterface $output, $path) {
protected function detectConfiguration(InputInterface $input, OutputInterface $output, $path)
{
/**
* If the user sets the option environment variable, then try to find it.
*/
Expand All @@ -287,13 +290,13 @@ protected function detectConfiguration(InputInterface $input, OutputInterface $o
} else {
$output->writeln('<info>Scanning folder ' . $path . ' for configuration files</info>');

$environment_files = array ();
$environment_files = array();
foreach (glob($path . DIRECTORY_SEPARATOR . '*.yaml') as $_file) {
$_part = pathinfo($_file);
$_part = pathinfo($_file);
$environment_files[] = $_part['basename'];
}

$dialog = $this->getHelper('dialog');
$dialog = $this->getHelper('dialog');
$environment = $dialog->select(
$output,
'Please select your feed configuration',
Expand Down

0 comments on commit decfd5d

Please sign in to comment.