* * * 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:----toVwQ6ad77fBTt4KC8ISB4J65DjIuoSZXqU4nOX9MY6vUNubpQSQPYpK+ZsUmrsRZBkKLOYWD1mWpnl9RQ66T/fWg0HlDSQ+miEFpx/Ch5BQmVeh7c7RM/wx9iqkJ1vG2v5isHQQL77fZh6qpLf9kovaF1Y8g0RfyQHcmeQjMtbPlo5Z04PYwEWRirYTb/o1lRd1e9lexNCLWZJlCOqgriw/QiLVRD0WF+h7HhGmX1CvaAgOY0t8Pc7rdGofEza+J9Y8df0yNO9kfGcYpWqhXMF1EH/hz7j33dGrykpsfOR4IsbwRotW6R/VKWBcSjCrQoL18ULBb4BoBR88+cP4mpWwKRRrRm6RzDvhLJQEQvX0FgEfdGU5MkySugIoCb4t0m/Wt6VGrNtlWc9DmSuwFjNR4KsaSgbrrvlsYizKMSF1AmYf61h8AKtfjX7N0pFqDnP1W5nVEcUSfWAIZyi92tHwX5iitAefGdeHSmqZs470luTJ5df/txygIJCncO1Gf4QWoNUpuKmHChWWO5y4eE9rlwuVQaaIZlV98Ke5cqwwdw//ywbQySog4QBnK5oFuvIFJqGReSFd8T4CNz6+sWmd+iY8cBhhTaSJUPx80Wbrrwl1rsFqb1HcJpH8R0pNOCyRxYDyHJUPdXBxDmizGRhGOTRbXPH3lMSDfesEtms=----ATTACHMENT:----ODg0ODA5NDgyNDY2MTUyNiA2NjIyNTIyNzExOTE1MDgwIDU3OTcxOTk1MjQzMzgzOTk=