Skip to content

Commit bb4f91b

Browse files
committed
some bug fixed
1 parent 1563091 commit bb4f91b

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

examples/HomeController.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ public function fmtMsgCommand()
151151
'see help' => 'please use php bin/app -h',
152152
'a only value message text',
153153
];
154-
Show::panel($data, 'panel show', '#');
154+
Show::panel($data, 'panel show', [
155+
'borderChar' => '#'
156+
]);
155157

156158
echo "\n";
157159
Show::helpPanel([

src/AbstractCommand.php

+6
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,13 @@ public function __construct(Input $input, Output $output, InputDefinition $defin
7979
if ($definition) {
8080
$this->definition = $definition;
8181
}
82+
83+
$this->init();
8284
}
8385

86+
protected function init()
87+
{}
88+
8489
/**
8590
* configure input definition
8691
*/
@@ -318,6 +323,7 @@ protected function showHelpByMethodAnnotation($method, $action = null)
318323
if (self::$annotationTags[$tag]) {
319324
$lines = array_map(function ($line) {
320325
return trim($line);
326+
// return $line;
321327
}, explode("\n", $msg));
322328

323329
$msg = implode("\n ", array_filter($lines, 'trim'));

src/traits/FormatOutputTrait.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,16 @@ public function helpPanel(array $config, $showAfterQuit = true)
133133
* @inheritdoc
134134
* @see Show::panel()
135135
*/
136-
public function panel(array $data, $title = 'Info panel', $borderChar = '*')
136+
public function panel(array $data, $title = 'Information panel', array $opts = [])
137137
{
138-
Show::panel($data, $title, $borderChar);
138+
Show::panel($data, $title, $opts);
139139
}
140140

141141
/**
142142
* @inheritdoc
143143
* @see Show::table()
144144
*/
145-
public function table(array $data, $title = 'Info List', $showBorder = true)
145+
public function table(array $data, $title = 'Data Table', $showBorder = true)
146146
{
147147
Show::table($data, $title, $showBorder);
148148
}

src/utils/Helper.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ public static function spliceKeyValue(array $data, array $opts = [])
284284
'sepChar' => ' ', // e.g ' | ' => OUT: key | value
285285
'keyStyle' => '', // e.g 'info','comment'
286286
'keyMaxWidth' => null, // if not set, will automatic calculation
287+
'ucfirst' => true, // if not set, will automatic calculation
287288
], $opts);
288289

289290
if (!is_numeric($opts['keyMaxWidth'])) {
@@ -323,7 +324,7 @@ public static function spliceKeyValue(array $data, array $opts = [])
323324
$value = (string)$value;
324325
}
325326

326-
$value = $hasKey ? ucfirst($value) : $value;
327+
$value = $hasKey && $opts['ucfirst'] ? ucfirst($value) : $value;
327328
$text .= "$value\n";
328329
}
329330

src/utils/Show.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -451,17 +451,23 @@ public static function helpPanel(array $config, $showAfterQuit = true)
451451
* Show information data panel
452452
* @param mixed $data
453453
* @param string $title
454-
* @param string $borderChar
454+
* @param array $opts
455455
* @return int
456456
*/
457-
public static function panel($data, $title = 'Information Panel', $borderChar = '*'): int
457+
public static function panel($data, $title = 'Information Panel', array $opts = []): int
458458
{
459459
if (!$data) {
460460
self::write('<info>No data to display!</info>');
461461

462462
return -404;
463463
}
464464

465+
$opts = array_merge([
466+
'borderChar' => '*',
467+
'ucfirst' => true,
468+
], $opts);
469+
470+
$borderChar = $opts['borderChar'];
465471
$data = is_array($data) ? array_filter($data) : [trim($data)];
466472
$title = trim($title);
467473

@@ -529,6 +535,7 @@ public static function panel($data, $title = 'Information Panel', $borderChar =
529535
'leftChar' => " $borderChar ",
530536
'sepChar' => ' | ',
531537
'keyMaxWidth' => $labelMaxWidth,
538+
'ucfirst' => $opts['ucfirst'],
532539
]);
533540

534541
// already exists "\n"

0 commit comments

Comments
 (0)