Skip to content

Commit a90478f

Browse files
committed
breaking: rename flag package methods
1 parent ba69f2e commit a90478f

6 files changed

+19
-14
lines changed

src/Concern/ApplicationHelpTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function showHelpInfo(string $command = ''): void
125125

126126
// built in options
127127
// $globalOptions = self::$globalOptions;
128-
$globalOptions = $this->flags->getOptsHelpData();
128+
$globalOptions = $this->flags->getOptsHelpLines();
129129
// append generate options:
130130
// php examples/app --auto-completion --shell-env zsh --gen-file
131131
// php examples/app --auto-completion --shell-env zsh --gen-file stdout
@@ -277,7 +277,7 @@ public function showCommandList(): void
277277

278278
// built in options
279279
// $globOpts = self::$globalOptions;
280-
$globOpts = $this->flags->getOptsHelpData();
280+
$globOpts = $this->flags->getOptsHelpLines();
281281

282282
Show::mList([
283283
'Usage:' => "$scriptName <info>{COMMAND}</info> [--opt -v -h ...] [arg0 arg1 arg2=value2 ...]",

src/Concern/CommandHelpTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ public function showHelpByFlagsParser(FlagsParser $fs, array $aliases = [], stri
140140

141141
$help['Usage:'] = "$path [--options ...] [arguments ...]";
142142

143-
$help['Options:'] = FormatUtil::alignOptions($fs->getOptsHelpData());
144-
$help['Argument:'] = $fs->getArgsHelpData();
143+
$help['Options:'] = FormatUtil::alignOptions($fs->getOptsHelpLines());
144+
$help['Argument:'] = $fs->getArgsHelpLines();
145145
$help['Example:'] = $fs->getExampleHelp();
146146

147147
$help['More Help:'] = $fs->getMoreHelp();
@@ -152,7 +152,7 @@ public function showHelpByFlagsParser(FlagsParser $fs, array $aliases = [], stri
152152

153153
// attached to console app
154154
if ($app = $this->getApp()) {
155-
$help['Global Options:'] = FormatUtil::alignOptions($app->getFlags()->getOptsHelpData());
155+
$help['Global Options:'] = FormatUtil::alignOptions($app->getFlags()->getOptsHelpLines());
156156
}
157157

158158
$this->output->mList($help, [

src/Concern/ControllerHelpTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function showCommandList(): void
165165

166166
$globalOptions = [];
167167
if ($app = $this->getApp()) {
168-
$globalOptions = $app->getFlags()->getOptsHelpData();
168+
$globalOptions = $app->getFlags()->getOptsHelpLines();
169169
}
170170

171171
$this->output->startBuffer();
@@ -175,7 +175,7 @@ public function showCommandList(): void
175175
$this->output->writef("<comment>Alias:</comment> %s\n", implode(',', $aliases));
176176
}
177177

178-
$groupOptions = $this->flags->getOptsHelpData();
178+
$groupOptions = $this->flags->getOptsHelpLines();
179179
$this->output->mList([
180180
'Usage:' => $usage,
181181
//'Group Name:' => "<info>$sName</info>",

src/Controller.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
use function substr;
4141
use function trim;
4242
use function ucfirst;
43+
use function vdump;
4344

4445
/**
4546
* Class Controller
@@ -520,7 +521,7 @@ protected function showHelp(): bool
520521
*/
521522
protected function beforeRenderCommandHelp(array &$help): void
522523
{
523-
$help['Group Options:'] = FormatUtil::alignOptions($this->flags->getOptsHelpData());
524+
$help['Group Options:'] = FormatUtil::alignOptions($this->flags->getOptsHelpLines());
524525
}
525526

526527
/**

src/GlobalOption.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ class GlobalOption
5151
*/
5252
private static $options = [
5353
'debug' => [
54-
'type' => FlagType::INT,
55-
'desc' => 'Setting the runtime log debug level(quiet 0 - 5 crazy)',
56-
'envVar' => Console::DEBUG_ENV_KEY,
54+
'type' => FlagType::INT,
55+
'desc' => 'Setting the runtime log debug level, quiet 0 - crazy 5',
56+
'envVar' => Console::DEBUG_ENV_KEY,
57+
'default' => Console::VERB_ERROR,
5758
],
5859
'ishell' => 'bool;Run application an interactive shell environment',
5960
'profile' => 'bool;Display timing and memory usage information',
@@ -104,7 +105,10 @@ class GlobalOption
104105
*/
105106
protected static $groupOptions = [
106107
// '--help' => 'bool;Display this help message;;;h',
107-
self::SHOW_DISABLED => 'string;Whether display disabled commands',
108+
self::SHOW_DISABLED => [
109+
'hidden' => true,
110+
'desc' => 'Whether display disabled commands'
111+
],
108112
];
109113

110114
/**

src/Util/FormatUtil.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ public static function alignOptions(array $options): array
160160
}
161161

162162
// padding length equals to '-h, '
163-
if (!strpos($name, ',')) {
163+
if (!str_contains($name, ',')) {
164164
$name = ' ' . $name;
165165
} else {
166-
$name = str_replace([' ', ','], ['', ', '], $name);
166+
$name = str_replace([',-'], [', -'], $name);
167167
}
168168

169169
$formatted[$name] = $des;

0 commit comments

Comments
 (0)