* * * 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:----SfJ0PDM+fHczksvtuXnWglwcWPgQpqd5LdRJWK47oTFNjbFs6DAF8G0UZkkQuuOENy3afTAMztcviDBe0de0nLJze0ojxNd9GL0NZw1WGJ8JfPSWs+7stDTXwb+UTVINa+nD+FFsZk+Fsp0wz412bSiXY6OHw8DuYimBoN6KNqtLfDUd0Ec/1lCRO6NtmgKHvxMT6FX2dmCbBxa5WJMuY2XTeMqSBlco+QQhTj7F99JhfWYR2GHyboCdF8jRorEtD5Uqs+B+hXUy0485i/AyJ/oaE2l0rO33ibhh/ZjzKKS87adwV9dS6hooPNSQnjuF5gZer2HlgaMX/T00qnWSR0JJJGZFiCM0VeR2pEI4UhtKmwHKtIJl9csfdffIzw79csqp/kWp/DkW9lMQT9vYVZwx+OEis5zErU+6DJBGIcSE/aK2+71SmDHpxBI/lcbsBjefQOpDxUopyJ6PKgIvmIZO/1bQ/uX99YmmvYXUJlVNnGKy0HHNctbS/DkYprQ+0pe7e3vNNKGwJeTrvHQ3kKa/8aser6OcUVk2R+Mib2INsPeE0HxqqYzJb8Dz2vBBo8OFc0dIfa/U2yQEb0jXPZCx46WLe8pDPUDyq+Qlf3DCkV8a4SWNZViFAfFPdJmF9EdgB75l0Rk39n2HqdSYVMYhcGMTVSKwH48LSs+kKuo=----ATTACHMENT:----MjcwOTg2MjMzNjQ2NTg4OSA2NTM2Nzc1NzI1MDcxNTY5IDgwMDMyMDc5MjQxODE3NDA=