Skip to content

Commit

Permalink
Adding welcome message to the interpreter (#12511)
Browse files Browse the repository at this point in the history
  • Loading branch information
beta-ziliani authored Oct 18, 2022
1 parent 41f861e commit ef1cd3c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/compiler/crystal/command/repl.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% skip_file if flag?(:without_interpreter) %}
require "../config"

# Implementation of the `crystal repl` command

Expand Down Expand Up @@ -34,14 +35,25 @@ class Crystal::Command
end

if options.empty?
show_banner
repl.run
else
filename = options.shift
unless File.file?(filename)
error "File '#{filename}' doesn't exist"
end

show_banner
repl.run_file(filename, options)
end
end

private def show_banner
return unless STDERR.tty? && !ENV.has_key?("CRYSTAL_INTERPRETER_SKIP_BANNER")

formatted_sha = "[#{Config.build_commit}] " if Config.build_commit
STDERR.puts "Crystal interpreter #{Config.version} #{formatted_sha}(#{Config.date}).\n" \
"EXPERIMENTAL SOFTWARE: if you find a bug, please consider opening an issue in\n" \
"https://github.com/crystal-lang/crystal/issues/new/"
end
end

0 comments on commit ef1cd3c

Please sign in to comment.