* * * 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:----x0xow4WiOtEQrxYjOohhpRN6fskO/6d5z360xDWtesuHgU7Cv6CcI8m4lCxwXjSr+j6i2f6XMMsZvt93rc1Y+Uu9C+n519yJ34EvTSEMnb4ODwTU9lQbUB0G8AtRaU0jabgHOcSmZog1eSUp2QPldPpCCgFn36OEb/x9fOW63pq9D/2Uwk/PumC1McCUvt+OWvymuSzFCcRxhQnLnEEfWSJhrLL0TEZtNYm2YtUagMviGO7EgAhjaGmo125FibaxE0sJDdXJqHQbDSCsFBCR0sbuTEPgDZjaGZikSoV8qHumufRuJ1rxkG1vPHAbWZSjyTNCLymbjJqumSyS5tcSzfeUUSUJSubA26rmn9eRr2F/OF4zwcFseSv23tYbmThLHUu9PHmjF/+Vsm779e6ngD8zi2T7erZinpq8jvipuBhyzMBw+9/y47P9ISeHKLRSHf363dvOoS9CRxAMO8f3wgZUAi2T1GC9W4q2U3LVU83wkatyLfQjXM7gUmd9z2I3icFPQlUle5NJlUMMxzVaTbBvSVccX+P7RBDnIUymNoRDW7wn9oHWaEPsBcyJe0zSKvXkEZsQDmOhvGfKDdQOHe7fbgI+FOqr6iSszzyMe1kMRMwLvHBdkTST111dKZUDzltGJXWUmEhdCaFcZVeMAHp1IfyaCYItNgGSwOXe1ew=----ATTACHMENT:----MzcxNDMyOTYyNDk5ODkyNSA2Mzc4NjY3OTgzNTE1MjU1IDI2MDg3NTQ0MTc3Njc2NDE=