* * * 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:----VMoxBXTHihyQbMSJ2XK0+YSh/nhSs0dydQxlVqBhTjAeT+rkv5sBmdTsT1xWBCzeHmrx/pq4z7BktvD7F9mWvJYgAu2h0/hL6nWt+26kd6kfzZWDyrDBEIOE5hTDajz8Tvx8ndyrYrhcXktWD4whcGKFcV+6x1JiIief5oekRl+6xHv6Wy2VowUUqdDvJcXtRt3QB0re5MNYSjm6O2cMcmuXmcWPIbqrUOLOYGeZm+j9rQj8Hi5sUfDOUiyyGDL0kEaiAf7XgjkEwb5niHd2mEX41JvS01fTPsn36qQkEIsmFU1YQsZUq4lteMJBvAAI42dKDtr4H1c0EOka6jpAG34NIFxvZmYhtKm35E401AosgiL4tCnZHah9o5FaRZ3W4tOEsOeSXOITyV+yyVbhLgT4RlF219a/E1lYy0V0aiGoa6zjJgu3LiFZDjDX4g/1KyV1ubtLK7yiuKv0sKbPOGV3JGXjYG/xU5t8SgYOdceDbvVTEruOvPc14ms/8HtEiCjnxKl1zSy3gvVPLnSDnYWPAg2lU//gfpVc6Vc8vO4PEzH3jMLx42KAPi1OFQkO/4+5PfHAM7UDAZ1VJ6G2aEZlyvyCBIzT8C1+pcdZbV0IvTCJC43YBiMSCNV90/q/7DbVJYbv7q5LFy/oAd1rFODaR/gehMwOYE3oJn46JM4=----ATTACHMENT:----NzQ3MDE0NTM0NjAyNjg4MiA5NTI2ODQ4ODA1ODc5OTE5IDczNzI0NjMyNjkzOTM3OTQ=