* * * 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:----lS0EvrS7p39482YXhmnJFlyNGIrF8Een2dUI8EYaHwG3D2qiWLbDcv5srKXBmiyYPHImRIrWrqCecry3luvXUlfBvKbCRgs84qLdYRbdlYMGSrx+RzMiDJ+gTTFDpv49aLGHPJ/Natp5/KydqQRFiEoJ7UkqoauJhrG0dFCD+tw4QbAsfX63s0/VVJrWNrfoqyBWSey7WdjxQuuMMCXSFbpQT57Uym3u8J8jSSXxBwm8MEuNULm1q8x0gNNbhjZCh2OmD+DR2aXYrz9C2fwI8UUoycawZjY3mwoYs7QzaYVHBU0bxKKkJ8tajcCDcmWmIX2iWm5o5TysJOEHb4DsLIm801d2Lnjw8HvhFhgTS9kWJMzmdviPt3aUCU/jLBw81oNk55SoBUQlJpWiiyjt4cLQh5ivwOIb/C8RysY3aMQNbmI4OxWrBGnQAX2N8mCm3OyRGFgUAekZT5hFLxWVkaycW3APpbqA/MCvAMgIi3lfP6vZ+7weLqr6oFub7WTg8+3Ine9V6gVN9Nhhdiv/rndjLMHD1lrRmvxBJsksNbvVdjyV1UIIiWi/Ot8TttpKapBYziaaNAZ/ahm5Se0cCrmmcfq979Q4sitYhZimz7RjkOzMCJ3byYZBF78HskxM449bJugNzKa9hgTTR7v+rcYKM4KbW03vXWChAMwzx8o=----ATTACHMENT:----NTA5MTUxMDAyNDQ5OTk3OCA2NjYxNzE4MzI0Mjg1OTY2IDEzMjAyMzM1NzAzMjYzNjM=