@@ -12,7 +12,7 @@ if (file_exists($autoload = __DIR__ . '/vendor/autoload.php')) {
1212 );
1313}
1414
15- $ options = getopt ('af:R ' ,array (
15+ $ options = getopt ('af:Nno:RV ' ,array (
1616 'append:: ' ,
1717 'debug ' ,
1818 'exclude: ' ,
@@ -24,6 +24,11 @@ $options = getopt('af:R',array(
2424 'memory:: ' ,
2525));
2626
27+ // option -V is an alternative to --version
28+ if (isset ($ options ['V ' ])) {
29+ $ options ['version ' ] = FALSE ;
30+ }
31+
2732if (!isset ($ options ['debug ' ])) {
2833 error_reporting (0 );
2934}
@@ -43,6 +48,30 @@ array_shift($argv);
4348
4449$ file = array_pop ($ argv );
4550
51+ // option -o is an alternative to -f
52+ if (isset ($ options ['o ' ]) && !isset ($ options ['f ' ])) {
53+ $ options ['f ' ] = $ options ['o ' ];
54+ }
55+
56+ // if both -n and -N options are given, use the last specified one
57+ if (isset ($ options ['n ' ]) && isset ($ options ['N ' ])) {
58+ if (array_search ('n ' , array_keys ($ options )) < array_search ('N ' , array_keys ($ options ))) {
59+ unset($ options ['n ' ]);
60+ } else {
61+ unset($ options ['N ' ]);
62+ }
63+ }
64+
65+ // option -n is equivalent to --excmd=number
66+ if (isset ($ options ['n ' ]) && !isset ($ options ['N ' ])) {
67+ $ options ['excmd ' ] = 'number ' ;
68+ }
69+
70+ // option -N is equivalent to --excmd=pattern
71+ if (isset ($ options ['N ' ]) && !isset ($ options ['n ' ])) {
72+ $ options ['excmd ' ] = 'pattern ' ;
73+ }
74+
4675if (!isset ($ options ['excmd ' ]))
4776 $ options ['excmd ' ] = 'pattern ' ;
4877if (!isset ($ options ['format ' ]))
0 commit comments