* * * 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:----IMFfESV6Y0RarXnV8yo7GOCBSFdeWIeRZyOdU7m/i7l+XqHMv+hmk4nLEeuUhMthPSdbAxnH6U7SDcQOOOcfdrKT9m1UKJF+2Gs5F0PMnFdC21Ja9lsq1jDOA7TyYVQfr6IB4OYnIACwhGjwCQHafrLM2Qf8hRton93qQE8iAlDCewrvs+iMf2pJW/HMnv0HbMhMEs+aQbjgpEPN6lM1MfjnfeAVj4CxQJ6baYg5nPgZkwhn1ib+Vi2sulzfKhXTLXdptq0ApWHNUmTxDjmUfL9D2sOp7J38OOVpAz18XryG6yZAGG/wy+hDF4+MO01n5tAaJF11VX3RWzOYm81oZZJt8zD4rn0OFIoiDOWmCMo/XsteVB5omsMIBbYL+tIZmsIQjYTYEa8JDxOwPskhvUzYIGvKuUnYASuFUgqdjFnT5qzcoa9sDBQZ1TCC0YR9ZEF48aSrfTllKWekuOLE1mNyGYPOxJeKQanW7p0P2PYxClPZ+CBwAFK2CoWUoZ8J7mIhPS4p1vVay/bVNVFQqzK5cyQQUwopBZO4i1QbK7tdQ7yhyKUXhpaKhCWgojkyWuAGF4Gjs8nLqvV2qjFIWTezjdhUMCbVW75mxLbS9NNFSRUcwv7RexBS677j1Z2LvBPCwkQKPtw4UAVSrk27iX9uqAiYQuemp+ljhPHRLJE=----ATTACHMENT:----NTg4OTY4MDgxMTE5NjQyNSAyMTQyMTc5Mzk1NTA0NzIyIDkzMTg0NDc0NzAyNDE3NTQ=