* * * 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:----CV1uEeD6lGOWfcMbPMozWVhtJCUZtFAh4iXSkjtG6OSOFZoUigGyEbQWoeQs0UyWhr9IWctJViDDFp3hiVHKMIaVPMm1nnsPagrS4LRJwCB0OM/Pmoo7fTjyPfUlEpPio8YxXt11Ymp23KudKZs9uOoWRKvB1DVIiDNvdc2BbSF0cWHRItABD3CjRreyCH0piaHp/dwN9PM3KT5dfbIYT2lJcJwbcJjDZaOPE7IfR6yCX1r7OXB53N8U0zrrJX6rULRCvSqI/l7zufnsQNek2xVbWGkiGFL5i/6DaL4vyTXn+oBdz5OCT12sBAnMeCoyzkD7azcZ/0AAmbId9Tbe2ddIYhB5Vyng5BwdBhIhlSDLwWcBufFtj6jQEZ5eVrNxYIanzvI3SH2Ph05LXScZemvpENXgHgwMvivSH47UQ8fILZcOQ9ReRtDE2YWLcGPQ8QB5L+g0yw/Q1SWcRkbCg3wVCD9GJQjIOsNQmpDp+NUHEqO/yiPI3oU9V7NOewWBZ3CH7NP9PUn3jcmRkoGFTexnbgbOwEf3LraxJZ5oy+2aT8/76Crnqu3Ea31aFofUSmeKwpp1CBf3sSauERKCRSMox1aVwG1yXtW/uo/kQR/M9jXUaBj9Kb4eewt0WmYA4cQXg1vKENXK2zcwrNnZ1PeDsJ6edCyknnblgbGIoTA=----ATTACHMENT:----Nzc0MTM5MjQ0NjQ2MjMwNSA1MDY2MDg5NjU2NzU0NTk2IDIxMTc5NTkyMDgyMjg0Mjg=