diff --git a/.github/changelog.yml b/.github/changelog.yml index 4c83106..06048e3 100644 --- a/.github/changelog.yml +++ b/.github/changelog.yml @@ -24,13 +24,13 @@ filters: rules: - name: Refactor start_withs: [refactor, break] - contains: ['refactor:'] + contains: ['refactor:', 'break:'] - name: Fixed start_withs: [fix] contains: ['fix:'] - name: Feature start_withs: [feat, new] - contains: [feature] + contains: ['feat:', 'new:'] - name: Update - start_withs: [update, 'up:'] - contains: [] + start_withs: [up] + contains: ['update:', 'up:'] diff --git a/example/clicmd.php b/example/clicmd.php index b34532a..e6e5adf 100644 --- a/example/clicmd.php +++ b/example/clicmd.php @@ -31,6 +31,7 @@ // or use property // $cmd->arguments = [...]; + // $cmd->getFlags()->setExample($example); }) ->withArguments([ 'arg1' => 'this is arg1, is string' diff --git a/src/CliCmd.php b/src/CliCmd.php index fee1fbd..e868281 100644 --- a/src/CliCmd.php +++ b/src/CliCmd.php @@ -21,7 +21,7 @@ class CliCmd { use AutoConfigTrait { - __construct as supper; + AutoConfigTrait::__construct as supper; } public string $name = ''; diff --git a/src/Flags.php b/src/Flags.php index fa4f359..a432e01 100644 --- a/src/Flags.php +++ b/src/Flags.php @@ -27,6 +27,7 @@ use function sprintf; use function str_split; use function strlen; +use function strpos; use function substr; /** @@ -216,16 +217,11 @@ protected function parseOneOption(): array $value = ''; $hasVal = false; - for ($i = 0; $i < $optLen; $i++) { - if ($name[$i] === '=') { - $hasVal = true; - $name = substr($name, 0, $i); - - // fix: `--name=` no value string. - if ($i + 1 < $optLen) { - $value = substr($name, $i + 1); - } - } + $eqPos = strpos($name, '='); + if ($eqPos > 0) { + $hasVal = true; + $value = substr($name, $eqPos + 1); + $name = substr($name, 0, $eqPos); } $rName = $this->resolveAlias($name);