* * * 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:----JkAb9+G6gpQsSA2KDlkMaN0psxLlZZBmfXOOl4PK174goHPfUA2uT6T5sjhfSF8wIB7KLkjDUil6pU1IOnF1e7U11aruv/iUs5XVsEEjSjbmkz1eAUfEi0usWlWQ6ftFqs97WQQijEGZr92nTDivU7LG8gKl8e1HFqp0I9vdbkmG8N2cDte94R5iYLpjf6A4Iu1jJOOPJcj7LWWeCqu6wzFM2opuAlmepKDgQ9zipa3yeESMRsvQRfrboCvmJTlpDWBJwqFRZWH9dO+A7UPnZia5l0jWx7nW85FwWUHPveQqX9zI8CUgL4JYXye9rg76OU4HH1jEnjKNGkFRKETVD7sFhTdS/sRQkfD8QSY0R0wLZHQjYwG+Juky31WtLU0Lebs2iKFNolhqrZ7E7lW+iyh3lzNxLMAQEz0CbXwCrqcPMJuqmMRvBus43ZAF0OFB6qX98NHMTUwEmBiXYqNuagUwh1qFeE3xsRj9RrLQwTceXN8L38qCxKsA3yJg86UqFupkDXFIEti5fQHiBam40lRmcRelLyYCllYOirvJFHI6BFTIhskh+pqLpFwHcKOnmeJHFJvdoihQtDALtRvBsiAuvaxgbsmaX4U0+o4ICW3GIzKGpoaRtxduExVnRS0Apx1EaHqiLHQs4jJpR0xuOuf9dS+KYuCqrCCy3jB9Ta4=----ATTACHMENT:----OTM5OTcyNDkyMDQ1NDI1OSA3NTk1OTkxMjEwMDI5Nzc4IDMwMzQ4MTQ0MDc1NjMwMA==