* * * 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:----u2Ca3dA6JS8gQO+9/PbEBF1DPGAvUP3uosYqKjypbJ3fq/ic0tA9FlruGGd9dbbl7uoW23OEPYlLzrHHmJKHoNCjg6okagFvoueCSgC56cx0pTz45SulDnCi6MiGIhnDmtI7I3Jvvto7ll+Itek2R5FDjVvuY8h9fj0YAHr6NqVkqWqV6BFXf6VnRIhzfyebOsEnbvduGW9oLcSn2RO8F/CiYu0LZxtz6QgTKlHFTdcWXG5N99BDEcPqL4W81k6YG9lZ+eZghCJVAHFG7FGxlUQDbBLOEzlOorJGTWeG0GczF6Ko2DYPhVmS1Vgy5reTSTFWEtJZovOSuGjBUwbq+m2iHwRRLil3WMiB7sw/ca17a+ufokgkv6Tr1lVvUJmY4FuDCP4spMNvwiei+7DoDqz4CVNmJrtkWlO9VV7DyVI2Vex+NYnDhK9rNGVITMuzaY1+fA4e74mmENh3AJonhwfpd3Q/wh8IogGk5BRt58lh+p7umFXDMNYVgPwRVgn5+Gt8h5Olb/6Rw6NKHXZYjW2jbP/X3DV+6YkDDq0kxJH449tSSwQ3Jg+/p78QDx0c317+3RmmvXUwWEOfbb20QqCmVOuxOrVsgzfO7GvwA1W3mQJrwQClUcWDkOSq0npx3jIoj8bR01jD6USeCkt8XDcTfGsr79vMVPjUF6qrMMY=----ATTACHMENT:----NTY1MDA1MDU1MDcxMjgwOSA3MTY3MTU2NzIyNDQ1MzQgMTA1Nzg2MTgzNDk1NTYzNA==