Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support -v, --verbose option #457

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/lrama/option_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
16 changes: 15 additions & 1 deletion spec/lrama/option_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down