pscss 886 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env php
  2. <?php
  3. error_reporting(E_ALL);
  4. require "scss.inc.php";
  5. $opts = getopt('hvTf:', array('help', 'version'));
  6. function has() {
  7. global $opts;
  8. foreach (func_get_args() as $arg) {
  9. if (isset($opts[$arg])) return true;
  10. }
  11. return false;
  12. }
  13. if (has("h", "help")) {
  14. $exe = array_shift($argv);
  15. $HELP = <<<EOT
  16. Usage: $exe [options] < input-file
  17. Options include:
  18. -h, --help Show this message
  19. -v, --version Print the version
  20. -f=format Set the output format
  21. -T Dump formatted parse tree
  22. EOT;
  23. exit($HELP);
  24. }
  25. if (has("v", "version")) {
  26. exit(scssc::$VERSION . "\n");
  27. }
  28. $data = "";
  29. while (!feof(STDIN)) {
  30. $data .= fread(STDIN, 8192);
  31. }
  32. if (has("T")) {
  33. $parser = new scss_parser("STDIN");
  34. print_r($parser->parse($data));
  35. exit();
  36. }
  37. $scss = new scssc();
  38. if (has("f")) {
  39. $scss->setFormatter($opts["f"]);
  40. }
  41. echo $scss->compile($data, "STDIN");