AndreyKo
AndreyKo

Reputation: 1481

How to run many mix phx.gen.html commands in one .exs script

I'm trying to rum many mix phx.gen.html commands from a script but only first command is executed. I tried different ways, some of them are below, but nothing worked:

Mix.Task.run "phx.gen.html", Parser.parse "Contacts Skype skypes user_id:references:users skype --parent user"
Mix.Task.run "phx.gen.html", Parser.parse "Contacts Phone phones user_id:references:users number --parent user"
Mix.Task.run "phx.gen.html", Parser.parse "Contacts Address addresses user_id:references:users country state region city zip street house corp flat  --parent user"

===========

commands = [
  "Contacts Skype skypes user_id:references:users skype --parent user",
"Contacts Phone phones user_id:references:users number --parent user",
"Contacts Address addresses user_id:references:users country state region city zip street house corp flat  --parent user"]


for command <- commands do
  list = String.split(command, " ")
  list = ["phx.gen.html" | list]
  System.cmd("mix", list)
end


for command <- commands do
  list = String.split(command, " ")
  IO.inspect list
  Mix.Task.run "phx.gen.html", list
end

Upvotes: 0

Views: 83

Answers (1)

zwippie
zwippie

Reputation: 15515

You probably have to reenable the task after you called it.

for command <- commands do
  list = String.split(command, " ")
  list = ["phx.gen.html" | list]
  System.cmd("mix", list)
  Mix.Task.reenable "phx.gen.html"
end

Upvotes: 2

Related Questions