sample.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Sample command.
  4. *
  5. * @command-handler sample
  6. * @command-handler-description Sample command.
  7. * @command-handler-header Windows Azure SDK for PHP
  8. * @command-handler-header (C) RealDolmen 2011 - www.realdolmen.com
  9. */
  10. class Sample
  11. extends Zend_Service_Console_Command
  12. {
  13. /**
  14. * Hello command
  15. *
  16. * @command-name hello
  17. * @command-description Prints Hello, World!
  18. * @command-parameter-for $name Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_Env --name|-n Required. Name to say hello to.
  19. * @command-parameter-for $bePolite Zend_Service_Console_Command_ParameterSource_Argv -p Optional. Switch to enable polite mode or not.
  20. * @command-example Print "Hello, Maarten! How are you?" (using polite mode):
  21. * @command-example hello -n:"Maarten" -p
  22. *
  23. * @param string $name
  24. */
  25. public function helloCommand($name, $bePolite = false)
  26. {
  27. echo 'Hello, ' . $name . '.';
  28. if ($bePolite) {
  29. echo ' How are you?';
  30. }
  31. echo "\r\n";
  32. }
  33. /**
  34. * What time is it command
  35. *
  36. * @command-name timestamp
  37. * @command-description Prints the current timestamp.
  38. *
  39. * @param string $name
  40. */
  41. public function timestampCommand()
  42. {
  43. echo date();
  44. echo "\r\n";
  45. }
  46. }
  47. Zend_Service_Console_Command::bootstrap($_SERVER['argv']);