* * * 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:----OeVJDj+eq6nN5O/MPsBWMqonBGcmJ9kseVLQeeFi0bHhfdnCfBcO7NIxatELkDEFvX3rJcVtWJNx0lq9NUjP524scV27LEtkBwu8fkR36i4wxZD/btcC8X+hFXCTCQtGga0eT2oFrxT+2wpleQJypQJJDT+Nz9oxFRsu7N7u3QHRJcRzGrGW+7WO/l3/pEJjgQmb6W/WTqGC1RfFmu/TnzB+zLf3ym61MxoBboUgSioyTWS/2lwJU4E0XlxSovER2/l9gIfiWVpHhna6HdMcF5+Go0/T5fGuO2ilKr3r0Twpucl88lRyIUKqJ4K22NUtwCHBmo3hMsIJkcOJkz0NkI6EC/0UPvrTx01Zlf6nWN2XZPvCN5+egWshM/vhFGD2hkeD78lPQiZ+cSb5No6ZnM241L7gmGwa/0+f5gdYqA0ozB0EIUtAWNIN2OvuFzThpWKB3gfCxpVTYm7XQJzDyEtYIF7SczbddAbttK7e+7v155ia5kVwpShpqEx1+b0rCdDbsAKJnZNLHG/CsVpgc11RXKLfounf0Tios73RIAa9Isv2L+1Q5hYgwkLeQEMlr8JnVJ1BP1wBTm/rdXwoDlN0FAhZbuV9/DKpcL3EZavHk0bP5iLO5IOpxT8DoFL2WCYhEM3spiLoKw3LOkfNui3ZPliIGdZk/u0VSM39fwE=----ATTACHMENT:----NzcyNjQyMzI2MDU1ODQ0IDUxNjQ1NDAzNzc3NjE0NzcgNjYxNzMwNjA3NTI5ODI2OA==