sample_cli.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * CLI script for colab.
  18. *
  19. * @package colab
  20. * @subpackage cli
  21. * @copyright 2020 Your Name <you@example.com>
  22. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23. */
  24. define('CLI_SCRIPT', true);
  25. require(__DIR__.'/../../../config.php');
  26. require_once($CFG->libdir.'/clilib.php');
  27. // Get the cli options.
  28. list($options, $unrecognized) = cli_get_params(array(
  29. 'help' => false
  30. ),
  31. array(
  32. 'h' => 'help'
  33. ));
  34. $help =
  35. "
  36. Help message for colab cli script.
  37. Please include a list of options and associated actions.
  38. Please include an example of usage.
  39. ";
  40. if ($unrecognized) {
  41. $unrecognized = implode("\n\t", $unrecognized);
  42. cli_error(get_string('cliunknownoption', 'admin', $unrecognized);
  43. }
  44. if ($options['help']) {
  45. cli_writeln($help);
  46. die();
  47. }