public static function getDisableANSI()
 {
     if (self::$disableANSI === null) {
         if (phutil_is_windows()) {
             self::$disableANSI = true;
         } else {
             if (function_exists('posix_isatty') && !posix_isatty(STDOUT)) {
                 self::$disableANSI = true;
             } else {
                 self::$disableANSI = false;
             }
         }
     }
     return self::$disableANSI;
 }
 public static function getDisableANSI()
 {
     if (self::$disableANSI === null) {
         $term = phutil_utf8_strtolower(getenv("TERM"));
         if (phutil_is_windows() && $term !== "cygwin" && $term !== "ansi") {
             self::$disableANSI = true;
         } else {
             if (function_exists('posix_isatty') && !posix_isatty(STDOUT)) {
                 self::$disableANSI = true;
             } else {
                 self::$disableANSI = false;
             }
         }
     }
     return self::$disableANSI;
 }
Exemplo n.º 3
0
 public static function getDisableANSI()
 {
     if (self::$disableANSI === null) {
         $term = phutil_utf8_strtolower(getenv('TERM'));
         // ansicon enables ANSI support on Windows
         if (!$term && getenv('ANSICON')) {
             $term = 'ansi';
         }
         if (phutil_is_windows() && $term !== 'cygwin' && $term !== 'ansi') {
             self::$disableANSI = true;
         } else {
             if (function_exists('posix_isatty') && !posix_isatty(STDOUT)) {
                 self::$disableANSI = true;
             } else {
                 self::$disableANSI = false;
             }
         }
     }
     return self::$disableANSI;
 }
 /**
  * Parse "standard" arguments and apply their effects:
  *
  *    --trace             Enable service call tracing.
  *    --no-ansi           Disable ANSI color/style sequences.
  *    --xprofile <file>   Write out an XHProf profile.
  *    --help              Show help.
  *
  * @return this
  *
  * @phutil-external-symbol function xhprof_enable
  */
 public function parseStandardArguments()
 {
     try {
         $this->parsePartial(array(array('name' => 'trace', 'help' => pht('Trace command execution and show service calls.'), 'standard' => true), array('name' => 'no-ansi', 'help' => pht('Disable ANSI terminal codes, printing plain text with ' . 'no color or style.'), 'conflicts' => array('ansi' => null), 'standard' => true), array('name' => 'ansi', 'help' => pht("Use formatting even in environments which probably " . "don't support it."), 'standard' => true), array('name' => 'xprofile', 'param' => 'profile', 'help' => pht('Profile script execution and write results to a file.'), 'standard' => true), array('name' => 'help', 'short' => 'h', 'help' => pht('Show this help.'), 'standard' => true), array('name' => 'show-standard-options', 'help' => pht('Show every option, including standard options like this one.'), 'standard' => true), array('name' => 'recon', 'help' => pht('Start in remote console mode.'), 'standard' => true)));
     } catch (PhutilArgumentUsageException $ex) {
         $this->printUsageException($ex);
         exit(self::PARSE_ERROR_CODE);
     }
     if ($this->getArg('trace')) {
         PhutilServiceProfiler::installEchoListener();
     }
     if ($this->getArg('no-ansi')) {
         PhutilConsoleFormatter::disableANSI(true);
     }
     if ($this->getArg('ansi')) {
         PhutilConsoleFormatter::disableANSI(false);
     }
     if ($this->getArg('help')) {
         $this->showHelp = true;
     }
     $xprofile = $this->getArg('xprofile');
     if ($xprofile) {
         if (!function_exists('xhprof_enable')) {
             throw new Exception(pht("To use '%s', you must install XHProf.", '--xprofile'));
         }
         xhprof_enable(0);
         register_shutdown_function(array($this, 'shutdownProfiler'));
     }
     $recon = $this->getArg('recon');
     if ($recon) {
         $remote_console = PhutilConsole::newRemoteConsole();
         $remote_console->beginRedirectOut();
         PhutilConsole::setConsole($remote_console);
     } else {
         if ($this->getArg('trace')) {
             $server = new PhutilConsoleServer();
             $server->setEnableLog(true);
             $console = PhutilConsole::newConsoleForServer($server);
             PhutilConsole::setConsole($console);
         }
     }
     return $this;
 }
Exemplo n.º 5
0
 public static function disableANSI($disable)
 {
     self::$disableANSI = $disable;
 }