-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathtable.php
More file actions
executable file
·62 lines (52 loc) · 1.5 KB
/
table.php
File metadata and controls
executable file
·62 lines (52 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/php
<?php
namespace splitbrain\phpcli\examples;
require __DIR__ . '/../vendor/autoload.php';
use splitbrain\phpcli\CLI;
use splitbrain\phpcli\Colors;
use splitbrain\phpcli\Options;
use splitbrain\phpcli\TableFormatter;
class Table extends CLI
{
/**
* Register options and arguments on the given $options object
*
* @param Options $options
* @return void
*/
protected function setup(Options $options)
{
$options->setHelp('This shows how the table formatter works by printing the current php.ini values');
}
/**
* Your main program
*
* Arguments and options have been parsed when this is run
*
* @param Options $options
* @return void
*/
protected function main(Options $options)
{
$tf = new TableFormatter($this->colors);
$tf->setBorder(' | '); // nice border between colmns
// show a header
echo $tf->format(
array('*', '30%', '30%'),
array('ini setting', 'global', 'local')
);
// a line across the whole width
echo str_pad('', $tf->getMaxWidth(), '-') . "\n";
// colored columns
$ini = ini_get_all();
foreach ($ini as $val => $opts) {
echo $tf->format(
array('*', '30%', '30%'),
array($val, $opts['global_value'], $opts['local_value']),
array(Colors::C_CYAN, Colors::C_RED, Colors::C_GREEN)
);
}
}
}
$cli = new Table();
$cli->run();