static function getConsole() { if (!self::$instance) { self::$instance = new Console(); } return self::$instance; }
static function getAdapter($adapter = self::ADAPTER_BEST) { if (!self::$adapter) { if ($adapter != null) { $objadapter = new $adapter(); } else { if (php_sapi_name() == 'cli-server') { $objadapter = new \Cherry\Cli\Adapters\NullConsole(); } elseif (_IS_LINUX) { if (getenv("NOANSI") == '1') { self::debug("Console: NOANSI envvar is 1. Falling back on simple adapter."); $objadapter = new \Cherry\Cli\Adapters\SimpleConsole(); } elseif (getenv("ANSI") == '1') { self::debug("Console: ANSI envvar is 1, enabling ANSI."); $objadapter = new \Cherry\Cli\Adapters\AnsiConsole(); } else { $out = null; $ret = 0; exec('tty', $out, $ret); if ($ret == 0) { self::debug("Console: Terminal seems to be a TTY, enabling ANSI."); $objadapter = new \Cherry\Cli\Adapters\AnsiConsole(); } else { self::debug("Console: No TTY. Falling back on simple adapter."); $objadapter = new \Cherry\Cli\Adapters\SimpleConsole(); } } } elseif (_IS_WINDOWS) { $objadapter = new \Cherry\Cli\Adapters\SimpleConsole(); } } self::$adapter = $objadapter; } return self::$adapter; }