* * * 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:----yFi06w8HwC29ECzXbAsAioTqImoW1MNg5NHx7yloW8+obZFZ9azkLDNxMUVTFuxUd1tLVocpi8aFFLUr/4pvQUNvfLss1TbT/Be077QrWEd1oP+spojs85cDHUGTzFpPXIh9lvd0LVnavPWIYsSwJMVsr3zT0ZpkVkuhFjR7+f7OYK2+UfWjXaKNFu2RH3glW4WitCnBuENLvfv6X6RZsLXnUy1FLhnL5r4TpBkmnZJvdnOTJad2mFlBLNpzjRAMHC7fbq5llfMh04PlYdoVWRQjHGYXZurqTPgUYc26L7jkv8C48r+LqVyQFQ8vTEWj/8oZBUgwNpIADlkcCMaCm2BVSKugCDUP/gFVwJrVeUujixzlAeXo3Q4kkbEdXxFm3AfIuy+L0dX0VDTzSGz79it5qnMTY5jjPuP5SggCCyKNn/m7lAyJ3bKsv7vqPRMdVMBFYhc/hEccBxZsomJUwfqk7h7tw4eBXrzVB0ibqY1MmyEqAk+zwecDOZbjlh0Ci8XIgG3mD1cH4r0VDjREcZikMRmJXO8jEwqE0PYONt6MvrujsuCwILvXSCJTrxsoBJI31EjW9AcyfO5oaykG3t3ebZLh5mqMq5cmifPXZpsgpdudNR4FFM9NQkL5Ury+mf8/JZevM64VEYF9aYEYYZZZ+mFsCNrlaxI/uZdz6go=----ATTACHMENT:----NjIxNzczMDgzNjE4NjMzMCA4MDYwODIxMzk1MDk1NzYxIDk2NjI4NzU3MTAxMjkwNTA=