* * * 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:----m2pNCWKAfBP0Tegb5UI47fIadoKpflyqoQfgJqWtJsYDIYqGa9kcyYcJgZq8NNQQt27ASCPvx3C9zsXCqgRJ3DAcd15bY17CXvZuKNnIxjYXbLOoeVW3V/cyMboPP3mZ0NvCB/Gva9NZNYIwongG97lz6YXU6zIOv6QxUPMv3zOqAzPYXNWU6e9ATBHB5qhqEfeCqN3AwM1puNQl0RLopOcWRAn+54JAlwroSDt96sXh7ipi1GHn3xWk9/evQDcTXzbF6p6GX7QgX9ujouqb6KMv4YoYOE5MHlM4p8SVT++rMEWuh1zJbNUBSVqJz4r2RgbmHcHVI9Prsf0+ZNo6wfzzlISYVEm1VyT9+JlOH0pBiJZPXs7R/lPFA7ZVcZQ5qGJCTqDdvIjM9oQ+ebHPfDFWyGdNaXdm/osGtTr6s7XsaFt1RL4Lu7batOK1yfxQ1SvON7Uj2kBKcFVui4y14T3sbZhX8jHqm2sTGXr6X1b5qB5kJknwmOwpLUUXc7cKgaKUaZxICwzhr8jrG6bdcNt1T+px5oJbBxLAH3ckCqg/Qaahbpv5FUZKcHS2VFnAooqC4++IdfFJdtH6iFuU1ptgpsJhQSY1DKMMolE4WiMnd1eIp0h18xOj47HArGoqKzbsmwp+mRQQ9L26VgaRF6Z6GIy2vAcPHUYIA+dRXII=----ATTACHMENT:----ODY1MDAzMDgzNDIwMjM0NSA5NDQ3MDg2MDA5Mzk2MDQwIDQ3NTIxNDgwNTQ3ODYzNDM=