-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_phpcli.php
More file actions
39 lines (33 loc) · 886 Bytes
/
test_phpcli.php
File metadata and controls
39 lines (33 loc) · 886 Bytes
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
#!$(which php)
<?php
require __DIR__ . '/vendor/autoload.php';
echo "Class::YourWork".PHP_EOL;
/*
** use splitbrain\phpcli\CLI;
** use splitbrain\phpcli\Options;
*/
//the head will come from head_of_phpfile.php
use splitbrain\phpcli\CLI;
use splitbrain\phpcli\Options;
class Minimal extends CLI
{
// register options and arguments
protected function setup(Options $options)
{
$options->setHelp('A very minimal example that does nothing but print a version');
$options->registerOption('version', 'print version', 'v');
}
// implement your code
protected function main(Options $options)
{
if ($options->getOpt('version')) {
$this->info('1.0.0');
} else {
echo $options->help();
}
}
}
// execute it
echo 'Will execute : $cli = new Minimal();'.PHP_EOL;
$cli = new Minimal();
$cli->run();