* * * 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:----fqlVeGNGserVblvbPb3oblJWEUVoLwYk0oqEkabrWYbYRQhkZ4Y/ETOqFiDS7QymM4bLt2I3PidOS0hxXF/7halaYh1CfIyEjUtzKd1UoUz1xchhQ9jd8ubRtxFl0QnSJXTELnze2/eKvZKatP101sboMTuSqdg/qKYT78aqfeCNQqX+KYJCQllPEcpGCva/u0MbA9DTlSXZNeu2ebs/DG9pRyE9Hi4c+DdZ+AeCzHZX+Pt73dJyXVbPNctM5y2FpOvJRpApPr/qW+9NviKBs+e1CN1AIG9nVG/d/3L4DcjqXRlJQ5yvX+oZWr3Wdfa/NuR429NrUG0mAJZ2RSrBj+pKy2Mrk4JlyojnXrqYwSIypQ5aiO1eZzR4qDg0xEACu/f6VWuNqFHT8EYEKQitjKWPm1yAA79LPXS5d+J5NLNHlUVfHWWYifXc+wdaW+ckZRDMGTzjY25iV/08yYzkMHMfAvPOtfY2nOSVQ8+L4uHXc54/EICfHKYAK3cnkXlcqdPt4YYi72ixAHFPhinjFLGIM9JzMhSTN6HrDnVSVHWTTGKiCVEws6QWOo6wx1AZAgwsBPuRNg2Jq/KAkg4kSkNtEnf5gELc83Qkn7Ny13e3PYtkBtaj8z25ZV0Qb5wNUKQF5Y0NJV7bsqcCBlv3yXSf6PTRYAXN6Ra3mw2C5fU=----ATTACHMENT:----NDg2NjAyNTk0NDM1MzQ4MyA4MzI5MTA3MjIwNTQ4MDA1IDc5OTU1ODc0OTMxOTk0NjM=