downloadServiceDefinition 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * This file is part of php-restcord.
  5. *
  6. * (c) Aaron Scherer <aequasi@gmail.com>
  7. *
  8. * This source file is subject to the license that is bundled
  9. * with this source code in the file LICENSE
  10. */
  11. require __DIR__.'/../vendor/autoload.php';
  12. use Symfony\Component\Console\Application;
  13. use Symfony\Component\Console\Input\InputArgument;
  14. use Symfony\Component\Console\Input\InputInterface;
  15. use Symfony\Component\Console\Output\OutputInterface;
  16. (new Application('Download Service Definitions', '1.0.0'))
  17. ->register('downloadServiceDefinition')
  18. ->addArgument('version', InputArgument::REQUIRED, 'Version to download')
  19. ->setCode(
  20. function (InputInterface $input, OutputInterface $output) {
  21. $style = new \Symfony\Component\Console\Style\SymfonyStyle($input, $output);
  22. $style->title("Downloading Service Definition for: ".$input->getArgument('version'));
  23. $file = __DIR__.'/../src/Resources/service_description-v'.$input->getArgument('version').'.json';
  24. file_put_contents(
  25. $file,
  26. \GuzzleHttp\json_encode(
  27. \GuzzleHttp\json_decode(
  28. file_get_contents('https://discord-service-definition.herokuapp.com/')
  29. ),
  30. JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
  31. )
  32. );
  33. $style->success('Finished. Downloaded to: '.$file);
  34. }
  35. )
  36. ->getApplication()
  37. ->setDefaultCommand('downloadServiceDefinition', true)
  38. ->run();