Skip to content

Commit

Permalink
Merge pull request #41 from ckrack/master
Browse files Browse the repository at this point in the history
Add format option to spark command
  • Loading branch information
jenssegers authored Mar 6, 2020
2 parents fc1a9e8 + 4e76f80 commit e7f95de
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions src/Commands/SparkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ protected function configure()
InputOption::VALUE_REQUIRED,
'The number of bits used to obfuscate the integer. E.g. 16 bits will produce numbers in the range 0 to 65535.',
Optimus::DEFAULT_SIZE
)->addOption(
'format',
'f',
InputOption::VALUE_OPTIONAL,
'The output format. Tip: Use --format=env to directly generate env variables.',
'txt'
)->addArgument(
'prime',
InputArgument::OPTIONAL,
Expand Down Expand Up @@ -59,19 +65,35 @@ protected function execute(InputInterface $input, OutputInterface $output)
return 1;
}

$output->writeln('Prime: ' . $prime);
$output->writeln('Inverse: ' . $inverse);
$output->writeln('Random: ' . $rand);
$output->writeln('Bit length: ' . $bitLength);
$output->writeln('');
$output->writeln(
sprintf(
' new Optimus(%s, %s, %s, %s);',
$prime,
$inverse,
$rand,
$bitLength
)
);
switch ($input->getOption('format')) {
case 'env':
$output->writeln('OPTIMUS_PRIME=' . $prime);
$output->writeln('OPTIMUS_INVERSE=' . $inverse);
$output->writeln('OPTIMUS_RANDOM=' . $rand);
$output->writeln('OPTIMUS_BITLENGTH=' . $bitLength);
break;
case 'htaccess':
$output->writeln('SetEnv OPTIMUS_PRIME ' . $prime);
$output->writeln('SetEnv OPTIMUS_INVERSE ' . $inverse);
$output->writeln('SetEnv OPTIMUS_RANDOM ' . $rand);
$output->writeln('SetEnv OPTIMUS_BITLENGTH ' . $bitLength);
break;
default:
$output->writeln('Prime: ' . $prime);
$output->writeln('Inverse: ' . $inverse);
$output->writeln('Random: ' . $rand);
$output->writeln('Bit length: ' . $bitLength);
$output->writeln('');
$output->writeln(
sprintf(
' new Optimus(%s, %s, %s, %s);',
$prime,
$inverse,
$rand,
$bitLength
)
);
break;
}
}
}

0 comments on commit e7f95de

Please sign in to comment.