Skip to content

Commit 38e2a94

Browse files
committed
Add support for --append option
1 parent 942b358 commit 38e2a94

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

phpctags

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ if (is_dir($vendor = __DIR__ . '/vendor')) {
1313
}
1414

1515
$options = getopt('af:',array(
16+
'append::',
1617
'debug',
1718
'excmd::',
1819
'fields::',
@@ -47,6 +48,14 @@ if(!isset($options['fields'])) {
4748
$options['fields'] = str_split($options['fields']);
4849
}
4950

51+
if(isset($options['append'])) {
52+
if ($options['append'] === FALSE || yes_or_no($options['append']) == 'yes') {
53+
$options['a'] = FALSE;
54+
} else if (yes_or_no($options['append']) != 'no') {
55+
die('phpctags: Invalid value for "append" option');
56+
}
57+
}
58+
5059
$ctags = new PHPCtags();
5160
$result = $ctags->export($file, $options);
5261

@@ -57,3 +66,13 @@ if (isset($options['f']) && $options['f'] !== '-') {
5766
}
5867
fwrite($tagfile, $result);
5968
fclose($tagfile);
69+
70+
function yes_or_no($arg) {
71+
if (preg_match('/\b[Y|y]([E|e][S|s])?\b/', $arg)) {
72+
return 'yes';
73+
} else if (preg_match('/\b[N|n]([O|o])?\b/', $arg)) {
74+
return 'no';
75+
} else {
76+
return false;
77+
}
78+
}

0 commit comments

Comments
 (0)