Skip to content

Commit 4bf9b97

Browse files
committed
Add support for --help option
1 parent 8f2f454 commit 4bf9b97

File tree

1 file changed

+58
-7
lines changed

1 file changed

+58
-7
lines changed

phpctags

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,68 @@ if (file_exists($autoload = __DIR__ . '/vendor/autoload.php')) {
1212
);
1313
}
1414

15+
$version = <<<'EOF'
16+
Version: 0.2
17+
18+
Exuberant Ctags compatiable PHP enhancement, Copyright (C) 2012 Techlive Zheng
19+
Addresses: <techlivezheng@gmail.com>, https://github.com/techlivezheng/phpctags
20+
EOF;
21+
1522
$options = getopt('af:Nno:RuV', array(
1623
'append::',
1724
'debug',
1825
'exclude:',
1926
'excmd::',
2027
'fields::',
2128
'format::',
29+
'help',
2230
'recurse::',
2331
'sort::',
2432
'version',
2533
'memory::',
2634
));
2735

36+
$options_info = <<<'EOF'
37+
phpctags currently only supports a subset of the original ctags' options.
38+
39+
Usage: phpctags [options] [file(s)]
40+
41+
-a Append the tags to an existing tag file.
42+
-f <name>
43+
Write tags to specified file. Value of "-" writes tags to stdout
44+
["tags"].
45+
-n Equivalent to --excmd=number.
46+
-N Equivalent to --excmd=pattern.
47+
-o Alternative for -f.
48+
-R Equivalent to --recurse.
49+
-u Equivalent to --sort=no.
50+
-V Equivalent to --verbose.
51+
--append=[yes|no]
52+
Should tags should be appended to existing tag file [no]?
53+
--debug
54+
phpctags only
55+
Repect PHP's error level configuration.
56+
--exclude=pattern
57+
Exclude files and directories matching 'pattern'.
58+
--excmd=number|pattern|mix
59+
Uses the specified type of EX command to locate tags [mix].
60+
--fields=[+|-]flags
61+
Include selected extension fields (flags: "afmikKlnsStz") [fks].
62+
--format=level
63+
Force output of specified tag file format [2].
64+
--help
65+
Print this option summary.
66+
--memory=[-1|bytes|KMG]
67+
phpctags only
68+
Set how many memories phpctags could use.
69+
--recurse=[yes|no]
70+
Recurse into directories supplied on command line [no].
71+
--sort=[yes|no|foldcase]
72+
Should tags be sorted (optionally ignoring case) [yes]?.
73+
--version
74+
Print version identifier to standard output.
75+
EOF;
76+
2877
// prune options and its value from the $argv array
2978
$argv_ = array();
3079
foreach ($options as $option => $value) {
@@ -46,14 +95,16 @@ if (!isset($options['debug'])) {
4695
error_reporting(0);
4796
}
4897

49-
if (isset($options['version'])) {
50-
echo <<<'EOF'
51-
Version: 0.2
52-
53-
Exuberant Ctags compatiable PHP enhancement, Copyright (C) 2012 Techlive Zheng
54-
Addresses: <techlivezheng@gmail.com>, https://github.com/techlivezheng/phpctags
98+
if (isset($options['help'])) {
99+
echo $version;
100+
echo PHP_EOL;
101+
echo PHP_EOL;
102+
echo $options_info;
103+
exit;
104+
}
55105

56-
EOF;
106+
if (isset($options['version'])) {
107+
echo $version;
57108
exit;
58109
}
59110

0 commit comments

Comments
 (0)