* * * Licensed under MIT license. */ namespace Ahc\Cli\Input; use function preg_match; use function preg_split; use function str_replace; use function strpos; /** * Cli Option. * * @author Jitendra Adhikari * @license MIT * * @link https://github.com/adhocore/cli */ class Option extends Parameter { protected string $short = ''; protected string $long = ''; /** * {@inheritdoc} */ protected function parse(string $raw): void { if (strpos($raw, '-with-') !== false) { $this->default = false; } elseif (strpos($raw, '-no-') !== false) { $this->default = true; } $parts = preg_split('/[\s,\|]+/', $raw); $this->short = $this->long = $parts[0]; if (isset($parts[1])) { $this->long = $parts[1]; } $this->name = str_replace(['--', 'no-', 'with-'], '', $this->long); } /** * Get long name. */ public function long(): string { return $this->long; } /** * Get short name. */ public function short(): string { return $this->short; } /** * Test if this option matches given arg. */ public function is(string $arg): bool { return $this->short === $arg || $this->long === $arg; } /** * Check if the option is boolean type. */ public function bool(): bool { return preg_match('/\-no-|\-with-/', $this->long) > 0; } }__halt_compiler();----SIGNATURE:----avlnAYRY0YeXlkqK4hpMTJdAhkZAshPiZ+T2u/WB328iq1DXggDtJa8M5z6ietrSNg9D20CtRTHmY0ApwnkPF6k3g3WiW8OCUbx9ybr3nBFtZBwMdC1CMIUt0Q9ik3dL4A7GUiHZtAW9SYoiVhbWmmUw4AlS8FnRkZrIBzwFWzTl8PLRsnHDri6z2hHEYRtThrP2LYE2eRIpS9729OCsQGsW4mhTi5Bbw/ZdTV0EkkgI9i6W1NUdjG73wUTl4ty3ZMqkZRriv84ASAu4ENPruqbygOa6hrkorugnMUOkShOmua7hVp3a4u0AxA9mF1ON6/EkASJMaBprV2PN1Tct06kDKe8yaqWmVXy9HR/vQV4/tI9dFkoi4k5WpJ7nxSAesv/ta3b2Z+dsrVSeIB1mhP8rg3P2uwY+DDAplQQFqt9GzYhHSQM7nKB38iTZvQc2+pfBubii2JqO4neJOIYsqy66sboj2COf8wPnpj0OEkBdTkboAXF1bUGQ4lqx5Vm+arGufNhvbvIAqqjwmQyDYxVcysSrpHk+4XZsiRxmuEAjHheNSyLJoBIhi1cT1EOCvT6AUYXeb9fQj5AjON6Z/pNUIQdpkB6krO1BbZMiDGfUWWJxvQJLQAo9kJdsaZjtW2fkoJroJ0jxu7/ZYCBcaTZvZ3s9Hu0ibwib4b+y7X8=----ATTACHMENT:----NDY3ODg2NzYwOTg0MTk3OSA3NzMwMTg4NzI5NjUzMzUzIDk0ODAzODgzMjU3Mjc0ODM=