Skip to content

Commit 37bcfaa

Browse files
committed
-m
1 parent 676171e commit 37bcfaa

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/AbstractFlags.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,14 @@ public function getRawArgs(): array
601601
return $this->rawArgs;
602602
}
603603

604+
/**
605+
* @return string
606+
*/
607+
public function popFirstRawArg(): string
608+
{
609+
return array_shift($this->rawArgs);
610+
}
611+
604612
/**
605613
* @return bool
606614
*/

src/Concern/RuleParserTrait.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,20 @@ protected function parseRule($rule, string $name = '', int $index = 0, bool $isO
123123
// set alias by array item
124124
$shortsFromRule = $item['shorts'];
125125
} else { // parse string rule.
126+
$sep = AbstractFlags::RULE_SEP;
126127
$item = AbstractFlags::DEFINE_ITEM;
127128
$rule = trim((string)$rule, AbstractFlags::TRIM_CHARS);
128129

129-
if (strpos($rule, AbstractFlags::RULE_SEP) === false) {
130-
$item['type'] = $rule;
130+
// not found sep char.
131+
if (strpos($rule, $sep) === false) {
132+
// has multi words, is an desc string.
133+
if (strpos($rule, ' ') > 1) {
134+
$item['desc'] = $rule;
135+
} else { // only type name.
136+
$item['type'] = $rule;
137+
}
131138
} else { // eg: 'type;desc;required;default;shorts'
132-
$nodes = Str::splitTrimmed($rule, AbstractFlags::RULE_SEP, 5);
139+
$nodes = Str::splitTrimmed($rule, $sep, 5);
133140

134141
// first is type.
135142
$item['type'] = $nodes[0];

0 commit comments

Comments
 (0)