FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
php-cli/examples/complex.php at dynamicLogLevel · splitbrain/php-cli · GitHub
splitbrain
/
php-cli
Public
Notifications
You must be signed in to change notification settings
Fork
40
Star
179
Code
Issues
1
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
php-cli
/
examples
/
complex.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
72 lines (58 loc) · 2.07 KB
Breadcrumbs
php-cli
/
examples
/
complex.php
Copy path
File metadata and controls
executable file
·
72 lines (58 loc) · 2.07 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/php
<?php
namespace
splitbrain
\
phpcli
\
examples
;
require
__DIR__
.
'
/../vendor/autoload.php
'
;
use
splitbrain
\
phpcli
\
CLI
;
use
splitbrain
\
phpcli
\
Options
;
class
Complex
extends
CLI
{
/**
* Register options and arguments on the given $options object
*
* @param Options $options
* @return void
*/
protected
function
setup
(
Options
$
options
)
{
$
options
->
setHelp
(
'
This example sets up additional subcommands using their own options
'
);
$
options
->
registerOption
(
'
longflag
'
,
'
This is a global flag that applies to all subcommands
'
,
'
l
'
);
$
options
->
registerCommand
(
'
foo
'
,
'
The foo command
'
);
$
options
->
registerCommand
(
'
bar
'
,
'
The bar command
'
);
$
options
->
registerOption
(
'
someflag
'
,
'
This is a flag only valid for the foo command
'
,
'
s
'
,
false
,
'
foo
'
);
$
options
->
registerArgument
(
'
file
'
,
'
This argument is only required for the foo command
'
,
true
,
'
foo
'
);
$
options
->
registerOption
(
'
load
'
,
'
Another flag only for the bar command, requiring an argument
'
,
'
l
'
,
'
input
'
,
'
bar
'
);
$
options
->
registerCommand
(
'
compact
'
,
'
Display the help text in a more compact manner
'
);
}
/**
* Your main program
*
* Arguments and options have been parsed when this is run
*
* @param Options $options
* @return void
*/
protected
function
main
(
Options
$
options
)
{
switch
(
$
options
->
getCmd
()) {
case
'
foo
'
:
$
this
->
success
(
'
The foo command was called
'
);
break
;
case
'
bar
'
:
$
this
->
success
(
'
The bar command was called
'
);
break
;
case
'
compact
'
:
$
options
->
useCompactHelp
();
echo
$
options
->
help
();
exit
;
default
:
$
this
->
error
(
'
No known command was called, we show the default help instead:
'
);
echo
$
options
->
help
();
exit
;
}
$
this
->
info
(
'
$options->getArgs():
'
);
var_dump
(
$
options
->
getArgs
());
}
}
$
cli
=
new
Complex
();
$
cli
->
run
();
Back
|
FazBrowse Home
|
New Git URL