application.php 808 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. require_once './vendor/autoload.php';
  3. /**
  4. * @var \YdbPlatform\Ydb\Slo\Command[] $commands
  5. */
  6. $commands = [
  7. "create" =>new \YdbPlatform\Ydb\Slo\Commands\CreateCommand(),
  8. "run" =>new \YdbPlatform\Ydb\Slo\Commands\RunCommand(),
  9. "cleanup" =>new \YdbPlatform\Ydb\Slo\Commands\CleanupCommand()
  10. ];
  11. if ($argc == 1 || !isset($commands[$argv[1]])){
  12. echo "Commands:\n";
  13. foreach ($commands as $name=>$command) {
  14. echo "- ".$name."\t"."- ".$command->description."\n";
  15. }
  16. exit(0);
  17. }
  18. if ($argc<4||substr($argv[2],0,4)!="grpc" || substr($argv[3],0,1)!="/"){
  19. echo $commands[$argv[1]]->help;
  20. exit(0);
  21. }
  22. $data = $commands[$argv[1]]->generateOptions(array_slice($argv, 4));
  23. $command = $commands[$argv[1]];
  24. $commands[$argv[1]]->execute($argv[2],$argv[3], $data);