Skip to content

Commit

Permalink
Fix validation and key creation
Browse files Browse the repository at this point in the history
  • Loading branch information
sjelfull committed Sep 7, 2018
1 parent 2c6beef commit 00e4224
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
19 changes: 6 additions & 13 deletions src/Command/CraftnetCli/CreateLicenseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,17 @@ protected function configure()
->setDescription('Create a license')
->addOption('edition', null, InputOption::VALUE_OPTIONAL, 'Which edition (defaults to standard)', 'standard')
->addOption('email', null, InputOption::VALUE_REQUIRED, 'Licencee’s email address')
->addOption('pluginHandle', 'handle', InputOption::VALUE_REQUIRED, 'Plugin handle')
->addOption('notes', null, InputOption::VALUE_OPTIONAL, 'Customer notes')
->addOption('pluginHandle', null, InputOption::VALUE_REQUIRED, 'Plugin handle')
->addOption('notes', null, InputOption::VALUE_OPTIONAL, 'Customer notes', null)
->addOption('privateNotes', null, InputOption::VALUE_OPTIONAL, 'Private notes', null)
->setHelp('Creates a new license for a given plugin and email.');

// extra command line arguments and options go here.
}

protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$input->validate()) {
$output->writeln([
"You need to provide all required arguments",
]);

return false;
}
$input->validate();

$client = new Client();
$data = [
Expand All @@ -42,15 +37,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
'email' => $input->getOption('email'),
];

foreach (['notes'] as $option) {
foreach (['notes', 'privateNotes'] as $option) {
if ($optionValue = $input->getOption($option)) {
$data[ $option ] = $optionValue;
}
}

$response = $client->createLicense([
'json' => $data,
]);
$response = $client->createLicense($data);

$output->writeln(PrettyJson($response->getBody()));
}
Expand Down
8 changes: 1 addition & 7 deletions src/Command/CraftnetCli/GetLicenseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$input->validate()) {
$output->writeln([
"You need to provide all required arguments",
]);

return false;
}
$input->validate();

$client = new Client();
$response = $client->getLicense($input->getOption('key'));
Expand Down

0 comments on commit 00e4224

Please sign in to comment.