diff --git a/lib/lrama/option_parser.rb b/lib/lrama/option_parser.rb index 6dbfc3ec..72999e1e 100644 --- a/lib/lrama/option_parser.rb +++ b/lib/lrama/option_parser.rb @@ -90,7 +90,7 @@ def parse_by_option_parser(argv) o.on_tail ' time display generation time' o.on_tail ' all include all the above traces' o.on_tail ' none disable all traces' - o.on('-v', 'reserved, do nothing') { } + o.on('-v', '--verbose', "same as '--report=state'") {|_v| @report << 'states' } o.separator '' o.separator 'Diagnostics:' o.on('-W', '--warnings', 'report the warnings') {|v| @options.diagnostic = true } diff --git a/spec/lrama/option_parser_spec.rb b/spec/lrama/option_parser_spec.rb index 57255fa5..eef10aa3 100644 --- a/spec/lrama/option_parser_spec.rb +++ b/spec/lrama/option_parser_spec.rb @@ -58,7 +58,7 @@ --report-file=FILE also produce details on the automaton output to a file named FILE -o, --output=FILE leave output to FILE --trace=TRACES also output trace logs at runtime - -v reserved, do nothing + -v, --verbose same as '--report=state' Diagnostics: -W, --warnings report the warnings @@ -143,6 +143,20 @@ expect { option_parser.send(:validate_report, ["invalid"]) }.to raise_error(/Invalid report option/) end end + + context "when -v option is passed" do + it "returns option hash states flag enabled" do + opts = option_parser.send(:validate_report, ["states"]) + expect(opts).to eq({grammar: true, states: true}) + end + end + + context "when --verbose option is passed" do + it "returns option hash states flag enabled" do + opts = option_parser.send(:validate_report, ["states"]) + expect(opts).to eq({grammar: true, states: true}) + end + end end describe "#validate_trace" do