diff --git a/src/compiler/crystal/command/repl.cr b/src/compiler/crystal/command/repl.cr index 1c0c91889bd1..d277332125a8 100644 --- a/src/compiler/crystal/command/repl.cr +++ b/src/compiler/crystal/command/repl.cr @@ -1,4 +1,5 @@ {% skip_file if flag?(:without_interpreter) %} +require "../config" # Implementation of the `crystal repl` command @@ -34,6 +35,7 @@ class Crystal::Command end if options.empty? + show_banner repl.run else filename = options.shift @@ -41,7 +43,17 @@ class Crystal::Command 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