* * * 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:----0Tn9ACHIxtvRMcBAxbL1keA3ytSg7tWm/9FadBiHfHfKfsrAlr8SKouSFdjF8DoyIp1sGlmh6VjIF6/gGdTSGCZmiut4kgOBwm8qO++fohuYw1s0qiyXCrkKIXr9IMYmzI+ME7TXfAfT9SsQJ0zlmHqyKWSDgRQMd7FiCQwnhHO7HzMsRh1jnfxJTgnabxloJRvODbVF76nu4F7CzpZVckT+6+nthFsuQnjF3oxIxS1YVbedxbPim4lnpZ/At8+97Kw7w7YEzOPC/sAGZbYS3YfUQZ4mi9a3FyL4z5yb5etPVDnx3JFqM9S5t2H+/ubvFJwqeGvPxI7+gTGqynvNzSQJs2OpGQSyCE8v/+Yjr3jrShc7v8irFGAe8ZLeBlTP8IAY3zeVIfv/oE0Iqmx5fK4YdaKUKn48ewFI/bBFLdtQALqc7aWs+aaIqsoXMZ9PS5V9dbasETDM8V+/TaXu6JdYl/hY+OwkjQR+vRxGgx1h4zBRZjD1GRE5Z/PcDbNx0rp1Hpts8IWc9fS92ZxBQCwpMuqTCDJPrLFCHaixdYVsLI2BUqTNNIK/aEolYaOjFmD5thU9Ks0PEAc31YuSB2Y5l58I/lfI+vFSQn2fESgzqa3pbIIRvvB+aJOUPoc9tB/z2QO3M2cfp5Dt2wuBIHuzExI5DY25ETDmScnm2fA=----ATTACHMENT:----Mzc2MzI0NjM4NjA5Nzc5MyA1NTM4NjY4OTE2OTU1OTQ4IDk1MzM0ODA2NTc4Nzc2OTk=