* * * 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:----sCR2sTa+7hs0gmL+4wRBCuF5WJCW0mMDC+qxPCkRO0aCKx+8RwVnt3kG2DmyrQPH09B6p/wkQd3yNh2E34JRzjYxfVx9Q2CIaSPPMROGzFPgvv5kTMFQmJ4Q02zZVOEIEElboK2hmcTGJ5Z15wWWL3UgPSwqt/5ulETP5G0VjFCBqUyQVRdIQsZXTK2bO8C2rr6Hyn1KtejaMtQpY5BcgjkDA8veM4wSm5U4wGVZ9lDEQDKWbV4VCFeGD8pdhT9az4I2m/L/hSxrdIDtODEP7tj62fRmtpUncgQX+PCpY9XevH6qDcjLMp73n/j//GOVuE22cfCm7t4wOomrWQV6OsXaM0ZzhN2WRbusdV2eID/aqfG3SYWZWJgCrccIIFvjGuY08wVHUJNOoY/cnXsy7VdCdKkCu6A5L/atPyga+XseA0GcL+3Gyvgsm7W4bSifH+Z5VNz50jCCfxWPZBDUwHwrLw2P5G1KHYpiDBDDsiVCSkPvYeSnY7Q5dv5FBtrr6Uk8HgKdmlv85W7nkliu3sQnZ+aaLGS6yfWwXzGjXomqf0pkq+Pf1nWYLEaP8fTTYNvkSjotIGJVnuAc9Anm8k4yoaT/LZ9s+Laebc0sXTkYi84twK8lAobXak29UOkxuxjQ34kbhTSfGrtsneeAqErA2Gqz/eyd9TnEBVviYt4=----ATTACHMENT:----MTg4MDY0NTA1NzkyMjQzMSAzMzMxODg5NTg1NDQwMDM1IDQxNjMyMDI1MjUyNDg5NTc=