Search code examples
crystal-lang

embed crystal-lang version in an application


I wanted to embed the Crystal version as well as the app version in my code. I came up with this:

  macro crystal_version
    {{ `crystal env`.stringify.split("\n")[2] }}.split("=")[1].gsub("\"", "")
  end

This seems a bit clumsy to me - all the array massaging and substitution. I'm also depending on the info I need being in the same place at a later date. Is there something within the language that I can use to accomplish the same thing?

Thanks for any insights.


Solution

  • You can use the Crystal::VERSION constant.