diff options
| author | Matthew Hall <hallmatthew314@gmail.com> | 2022-09-04 14:11:20 +1200 |
|---|---|---|
| committer | Matthew Hall <hallmatthew314@gmail.com> | 2022-09-04 14:11:20 +1200 |
| commit | 221d689daf4637c7169f9104df0d4b66d00d0370 (patch) | |
| tree | 7cd27945652e8cece7a396f93e2fdeedc50f0697 | |
| parent | b51ed9b9736eb0b333585b0b9cb1797054c4b69f (diff) | |
Re-write source selection to not use the not_nil! method
| -rw-r--r-- | src/flint.cr | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/flint.cr b/src/flint.cr index 89f1d3f..02255b2 100644 --- a/src/flint.cr +++ b/src/flint.cr @@ -55,12 +55,9 @@ module Flint parser.parse - if read_stdin - source_io = STDIN - elsif !source_file.nil? - # compilier complains without the not_nil! - source_io = File.new(source_file.not_nil!) - else + source_io = read_stdin ? STDIN : source_file.try { |f| File.new(f) } + + if source_io.nil? puts "ERROR: No source file chosen" puts parser exit(1) |
