choice('Select', $options, $default, true); static::interactor()->greenBold("You selected: {$options[$option]}", true); // return $options[$option]; return $option; } /** * @use 确认 * @param string $msg * @param string $default * @return bool */ public static function confirm(string $msg, string $default = 'n'): bool { $confirm = static::interactor()->confirm($msg, $default); // Default: n (no) if (!$confirm) die(); // if ($confirm) { // is a boolean // static::interactor()->greenBold('是 :)', true); // Output green bold text // } else { // static::interactor()->redBold('否 :(', true); // Output red bold text // die(); // } return true; } /** * @return \Ahc\Cli\IO\Interactor */ public static function interactor(): Interactor { return static::$interactor ?? static::$interactor = new Interactor; } }