summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Hall <hallmatthew314@gmail.com>2022-09-04 14:11:20 +1200
committerMatthew Hall <hallmatthew314@gmail.com>2022-09-04 14:11:20 +1200
commit221d689daf4637c7169f9104df0d4b66d00d0370 (patch)
tree7cd27945652e8cece7a396f93e2fdeedc50f0697 /src
parentb51ed9b9736eb0b333585b0b9cb1797054c4b69f (diff)
Re-write source selection to not use the not_nil! method
Diffstat (limited to 'src')
-rw-r--r--src/flint.cr9
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)