jungen 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. include ('api.1984tech.php');
  3. $tech = new OrwellWorld();
  4. //need at least 1 command line argument
  5. if ($argc >= 2) {
  6. $allowedOptions = array(
  7. '--preview' => 'preview JunOS address list update script to stdout',
  8. '--resolve' => 'render IPs list of loaded domains',
  9. '--help' => 'show small help'
  10. );
  11. $option = $argv[1];
  12. if (isset($allowedOptions[$option])) {
  13. switch ($option) {
  14. case '--preview':
  15. print($tech->getJunosScript());
  16. break;
  17. case '--resolve':
  18. print($tech->renderDomainsIps());
  19. break;
  20. case '--help':
  21. print('Usage: php cli/jungen --option' . PHP_EOL);
  22. print('Available options:' . PHP_EOL);
  23. if (!empty($allowedOptions)) {
  24. foreach ($allowedOptions as $optionName => $optionDesc) {
  25. print($optionName . ' - ' . $optionDesc . PHP_EOL);
  26. }
  27. }
  28. break;
  29. }
  30. } else {
  31. print('Unknown command line option: ' . $option . PHP_EOL);
  32. }
  33. } else {
  34. //option requirement notification
  35. print('At least one option required.' . PHP_EOL);
  36. print('Usage: php cli/jungen --option' . PHP_EOL);
  37. print('For example: php cli/jungen --help' . PHP_EOL);
  38. }
  39. ?>