您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

51 行
925 B

  1. #!/usr/bin/php5
  2. <?php
  3. $aliases = array(
  4. "-o" => "--save",
  5. "--output" => "--save"
  6. );
  7. $ctx = pipi_create_context();
  8. $list = pipi_get_command_list();
  9. for ($argi = 1; $argi < $argc; $argi++) {
  10. $arg = $argv[$argi];
  11. if (isset($aliases[$arg]))
  12. $arg = $aliases[$arg];
  13. if (substr($arg, 0, 2) == "--") {
  14. $cmd_name = substr($arg, 2);
  15. if (!isset($list[$cmd_name])) {
  16. die("unknown command $cmd_name\n");
  17. }
  18. $cmd_argc = $list[$cmd_name];
  19. if ($argi + $cmd_argc + 1 > $argc) {
  20. die("too few arguments for $cmd_name\n");
  21. }
  22. switch ($cmd_argc) {
  23. case 0:
  24. $res = pipi_command($ctx, $cmd_name);
  25. break;
  26. case 1:
  27. $res = pipi_command($ctx, $cmd_name, $argv[$argi + 1]);
  28. break;
  29. default:
  30. die();
  31. }
  32. if (!$res) {
  33. die("command $cmd_name failed\n");
  34. }
  35. $argi += $cmd_argc;
  36. }
  37. else {
  38. if (!pipi_command($ctx, "load", $arg))
  39. die("could not load $arg\n");
  40. }
  41. }
  42. ?>