* * * 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:----rLdq6kWqhYvYBhfuUHT2h8lEZv6nysg8M43UoAPyM7vgErExyySCdWKSs6idkbgnAelhMUCfn7/956VSCAY65WmFwRYMy77ev1c0uHsD2rd7BJ2hCFTldR2HijPLcCVqJ9JOxrFyeZe3zKxWyBUXrRf5f+cAQpQ6uivJsPFYN9gRb2qblW/WIS9ChwOd7McpSZdCRpGp+qd/2IU90Jg21R4z7IR6o72tu3twk9XpGZsoprtH7llavnarYTmHDS4Gl9vLEeKOTY2PamTSAJ5zBvv4n6naMclzqProh9fx5W6K32/Dm9Kuuqca9lLzpksIAhtLcxZ+E25xbGLKBEc202LpOgBOZBvfw+dPYTaOzwNBu9bafATUo6uPnJjkhMiGD7EDybPd9k6dFNS+OuGIOjIGjBcYuCEV9/7bSWYRSa3kWLWyKWyxobYn7KDDv1RNWYpn5lenweDQwcI5HtPcRnzJi91jZYAvWegWFS5sCOpcpyM6L31P+UBnu90Rhr8KAU/fmIIljnj3nrUwA+it0ShYcuNmF+J1irj7jr0GI2Sy4PFqpKOn5AimnCOTOX5fbw1abZpMQBHF/67Hv2lTWJ2bXv9R9QDIIdZZ2Z+uYI1e48eD+d8JV0nNwwORvGDILfUtDEx6EzQhm8RwZNxrJCLczKyK4vZ4p4so6rR8SiA=----ATTACHMENT:----OTk4NDQzMTIzNTM2NzUxNSA1MDA2MDQzODE3NDQwMzI3IDM1MzYyMDc3MTU2ODc3NzI=