* * * 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:----WrlN8NVWTXpEAAXHtg1OXzlpRfYGTu4VtYZd2Q4YGBoQHo7gxhD2ei3eyNarsuSqdXfxcL4RyjKASjBefOIWog2t/XOtUyKxO5A67QJSv+Jcs8pRaN2YkT+GiOz3x7WYCVFbFaO+Ux4f+Q29fFF0zAFWxD9CJWxo3HE06c5tq4hY1M3iwhCGp4CaSj3BzfJQ/kn4GwOOvtKe58J6uXhzNwwGZZ/E3Jij3G2kgrvIWTftKb7IhOGUKtWUqx5e21jXNe+qWH7HME+W1WVe5GSylAoTtBhgtkGhY8g5B72P5TI4FQIObVpSUgL6/3dvphg/uCZ4dUz1p1w+yGaEEBvCErzMik82tU837IwUNatl3VhrYDuQIXsTty2Ind/1F3ioByBJVugYr+tcEKwOHUfR57pwrK1u7PnVuKi3z8q+WIPgPgcgiXZUuayMB/+jKEXsb0lEWw1xFjwg+hLRevAwFbqKkqk4bmj4YwAmhVaNAICNd1Tx3mZQ/V0N0ll/dgeU9Bue4KNdl0GjIg4kpY+3B/JdUvOPZP4OecPTI/YDsWRGGF5myMyMgXvq8ogoMySFe6615D4WlVSfoR/1ioOWzlySno2gyh9q+HRfEtnGIkn3EPWpPj6bPFdbqx9yojkskGkBcOc6eZNI/IAoaWiFTm63m4xb0nxVr+NmdWY7Rbg=----ATTACHMENT:----OTM5MDI3NzIxNjQ3NzYyMiA0OTg3NTczMzI3ODgxNTc2IDM0NTE0NTI5ODczMTczNDM=