* * * 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:----FQKS3ljBtDDuKZpVAbXnooUfrZQMdQlOfkYLaWmWbxC0SK+qP2T234LoRkU58fpNdEDtbYLZg6jsOxH18w1JTiSzbSFj1dc/ziPY/W92v4qCE5KZJQSMpdfAuNzvzTWngOOUoRj9UGINtsVTZcxED0LWAkOwsiNALcqGbySU3NTr32FhkiOG3kx0jXJh6w8ILlZI799oAR3PI/8uwgqMvgMHUADSeVV3SuNE1nNAbj05CHnZdGETEOR0qO2ue969UK9LzTd3VlYheJ/n1ZPX8lULbfc6BjJEJ7CJ8BPvpx2pjvWXGuo98aFx0dEv61osnN6F0zbsVBNuunuZ4AUuCBzqG83mulN8Umi3k5GA2cPmcxUzkDqtMnUs4y3KNHHDdFa5oUE9J1nIFeyRmNlfrUDjEYp6HTNzt9ef4HfQbh66UHP6Zx/+rm6ajJDQJOp4u8xzZ9wX/mjGwDd1cO9O41a0+TxDSyXUR9ZY7i+aTrxUnxLwC0Q3/Rlw2Z86toed1Ykpny5DBoJCLtwmHdggkCDTIqPjua8akHah8piUoZeg7AEuRY4En2Yf8oJ0Meh+XbD52Ixb7adpvk99OgEuO0auEzUYbhk29LoulgVWcCAeL0khy2Rb+rmuNhBN9cZGh1wJo9pchymfYexQes2bgmHLmmHqiAjlrfi+Xe6QNeo=----ATTACHMENT:----OTU5NzExMTI2NTMxODUyNSAzMDA1NjE0MTc1MDk0NDUxIDc1Mjg4MTI1OTY5MzQ5MjA=