From ef1cd3c1c33dad55ef1a05f79b43624c0747489f Mon Sep 17 00:00:00 2001 From: Beta Ziliani Date: Tue, 18 Oct 2022 07:29:40 -0300 Subject: [PATCH] Adding welcome message to the interpreter (#12511) --- src/compiler/crystal/command/repl.cr | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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