* * * 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:----hA8cEiVIM/cdNTHvJhAEzyyd9DWR0WY08ezdJ0om9SwsGDQSpbhp2wStggemeS2AeYddYGbEKltu3yISHS+tXzd0Wu3aylSJlpY18AZukuZivG+q3L0iGrX4S7RvH3GRiLB7c41XvixEYjF+BEwisAOreI+Iv7+OriWv4jilsDNdWp1fmZeK0nxsxaNVE+3D+7cA+oh559DqBYiliM3TSAXQZxsernFTbtgEGglP2TWbzFOOt4EAM8PFjFRiH+2pR90R3p+vSaD3wLXtz8mllVb+D1WE0/ug5MpfCf8lqtXS83rXvkTEjUJ0l6teDopyS7KtE8w+pkZAGNDZXGikSp0LL4x5aU6TBWrTWf6QZ0gp5V2RWmr9rBUJVZlmaBKpLRoMpNnJHRuDGQdMQAkvA5D0/qwGkae0ziD1VyYR/8YDENdwchym9rMezIFhzNLdfdlmvOXSkDygv4gYOaf1/po4Z60fFl57/07XDrdiGRmZfhbGwNJWwgBQE3u9lCDcm08SQE4gSOPNc3vWdtPDMzm8bdA3lp4AVtN+dRJAa87Bk7dTwz6OX1woCiGgFiVEpuFziFdGmIDI+cJV8d33spkR3PbXiD/nbETcl0XchxNGsGcsHzQm6cRBM4Pn3pi1AuK1y1hx49zR1YUJi2DT9IYypZ7B7Rh7FAbPBHVxBZ0=----ATTACHMENT:----MjMyNjQyMDY1ODk5NjU5MCA4NDc0NDc1Mjk3OTkxMTQyIDg2OTgzOTIxMzYyNzE2MTA=