-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathmultiple.php
More file actions
executable file
·48 lines (39 loc) · 1.23 KB
/
multiple.php
File metadata and controls
executable file
·48 lines (39 loc) · 1.23 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
#!/usr/bin/php
<?php
namespace splitbrain\phpcli\examples;
require __DIR__ . '/../vendor/autoload.php';
use splitbrain\phpcli\CLI;
use splitbrain\phpcli\Options;
class Multiple extends CLI
{
/**
* Register options and arguments on the given $options object
*
* @param Options $options
* @return void
*/
protected function setup(Options $options)
{
$options->setHelp('This is a simple example, not using any subcommands');
$options->registerOption('multiple', 'This option can be specified multiple times.', 'm', true, '', true);
$options->registerArgument('argument', 'Arguments can be required or optional. This one is optional', false);
}
/**
* Your main program
*
* Arguments and options have been parsed when this is run
*
* @param Options $options
* @return void
*/
protected function main(Options $options)
{
if ($options->getOpt('multiple')) {
$this->info("multiple was given as " . implode(", ", (array) $options->getOpt('multiple')));
}
$this->info("Number of arguments: " . count($options->getArgs()));
$this->success("main finished");
}
}
$cli = new Multiple();
$cli->run();