Skip to content

Add mix eval#11861

Merged
josevalim merged 5 commits intomainfrom
jv-mix-eval
May 31, 2022
Merged

Add mix eval#11861
josevalim merged 5 commits intomainfrom
jv-mix-eval

Conversation

@josevalim
Copy link
Member

The goal of this task is to have an equivalent for bin/my_app eval in releases, so developers can easily run commands that apply for both releases and regular code.

My biggest concern is if the differences between mix eval and mix run are clear in the docs, so feedback on this area is welcome!

Copy link
Member

@whatyouhide whatyouhide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of small comments but looks pretty good to me 💯

@moduledoc """
Evaluates the given code.

mix eval "IO.puts 1 + 2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick (non-blocking): Maybe we can add parens so that the Elixir code looks more "idiomatic"?

Suggested change
mix eval "IO.puts 1 + 2"
mix eval "IO.puts(1 + 2)"

@@ -0,0 +1,73 @@
defmodule Mix.Tasks.Eval do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question (non-blocking): Noob question: after reading the docs, my natural question would be "With mix run I can run code or files in the context of my started application, but here it seems like I can only eval code (and not run files in the context of my loaded application. How do I eval files?". 🙃

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. We definitely need to answer this question and actually explain when you would want to use this. I will improve this later.

@josevalim josevalim merged commit f7e5887 into main May 31, 2022
@josevalim josevalim deleted the jv-mix-eval branch May 31, 2022 12:52
@josevalim
Copy link
Member Author

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants