* * * 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:----K8SQmgxNrdb2EbauAmE7/FVsLuBTOuh4NdBepciOOisXQILEm5C+C4hA8xrxtP7AvpHZbnGXXAzP2mlh+A6m5MaoD5xfE2jdCrkCyT5d9sETzCe4T+cwdh20GvaC859qCJmDiCsHfvcy8iREULHa35ItPQoLszdmnFsp+ESmdXEmBbK7SnAGH+PiuzIj9lOXQ2ZqFkeGibW/ntI1lKKZ/Ml0UqbhpQTjQkmuYbci2XedfcNgpzcFK0IkUvg5w75S73pC1mkwy0TfDaKFhbrwukgnNkLfroXJAs98cM0I2Pw0mIH4jFHm89sT1ibKQtOXxCPSVK1uIM0KQUZdwVizQoz0BRtDtFxQTHdhmV3YEF4q10maODOgK7zkgdVKfcW+/xjMDAsZR3H0YxyHRSbxbk+sr+4R1yn04ibf1ISCT2wzNDde9npKggR5j9v7ieJR6LBcxTJzHd+QGQDjE9OKf/v3rPWcX+OuTnhQzLcSH2m+2UXMNrzkB0pLlgwjtMJ7MHRTARCsQORveG/HhpmDwPnM7gsf10C9vsrxKvBczkHSIDmNRLOG/MdBdDuJ4OQWrp44CEpFJlfxkJ1K/dR5U8MX3x4U8WaDhjLnXEaUA9k5diyiykydu612Xg+jnOq5z84jO6Ut3H97ppfsLi4T/qNaBKDst2XpnvwIOvWJQaY=----ATTACHMENT:----OTg1NjQ3NjczMjgxMTI2NiA0MDkxMjE3NTk4NjIxNzEgMzY1MzMzMjk1MjYzMzExNQ==