* * * 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:----Rw8yJlsBwtIKOdv8pUZBSCwZAoIWKlZ3lJSBVz6hiZFCvhVgLlCzrEW+lMWcCdx8swYL7w2JT5mzw1M9g73SRnBcKClZ4WaODIl9XNLgywKqnJcNGNNOio1sYyqfo/D6Zrb7I0PMBo7aNqT/piD5a7v+MYpIc/wpXRe49SFYV99IomiLRfvUl0NQAoT6MfZG1mFQ3rD4jx0hWarl5CJA9VkjTZ7uTcnKglusPDlJ6w+2t37sQQsLCtGcsfL7yfM1H99qSVUrdCNxN7KX2Gj2ibGvivLOzf2Jlz7QGsZhmDqOs6Y1H3g4/8FhF4dIDBWu0/+CtLrwUgRXqpDRbmd1/eQV+Bs9s04Pn7pVl9ryaprpTL8Ajwit/TrhMJQrudk7KRuMhjXJMVgFeh1Ja7bkHCgyEzUz2TpoBxS6SogEPCuK+GtBQ7CFZCFe2+IfoK+5cpyOV+LS2DzRyyvQiCNsrUjoE2W830M1vEmWsMRPjlbSyDbKc5H3/qWUFVkL8Ka+Jn5ov/+vRcp6jV+50x329Y+hEWvOMH92JyqEuNtg8yrUeyX9Pwax/munL4xs0OrefR0oALemxlDlvmVFspWLcuGWR/UeBdjtFF6M6GtVDMMrETfzx1n3tyJKGvAmhxKn2CMLBE4hI2sqYi+JdZ3b6WGhuyvJLMaaC9nfJF5upyo=----ATTACHMENT:----MjU2NTYwNzkxMzk2OTAyNyAzNDc1NDE1MjM5MjE1Njc1IDc1NzIxMDI5NDQ5NjQwNDI=