granyatee

granyatee

Multiple elixir commands on iex -S mix

Is it possible that I execute two different commands when I use iex -S mix like you can do un unix bash using the && operator?

Edit:
i.e.: I want to reload a module and test one of the module’s functions something like
r App.CoursesModule && App.CoursesModule.list_courses()

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

The REPL executes elixir code, which generally means functions are called one per line. So you’d do:

iex(1)> IO.puts("hello world")
hello world
:ok
iex(2)> IO.puts("wazzup")
wazzup
:ok

You can put multiple commands on the same line and execute them unconditionally by separating them with a ;

iex(3)> IO.puts("hello world"); IO.puts("wazzup")
hello world
wazzup
:ok

You can use && to conditionally call functions as long as prior functions returned something “truthy”

iex(4)> true && IO.puts("wazzup")
wazzup
:ok
iex(5)> false && IO.puts("wazzup")
false

Basically it’s just Elixir code.

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hey @granyatee are you talking about running multiple mix tasks, or executing multiple commands inside the REPL that iex provides?

eksperimental

eksperimental

if you are talking the mix command, you can achieve that with mix do
for example:
mix do task1, task2, task3

Where Next?

Popular in Discussions Top

marciol
Please, let me know if this kind of discussion already took place in another topic . Hi all, how do you consider if is better to build ...
New
WolfDan
After doing a port from a c++ library to my project in phoenix I’ve seen that I need a faster way to run this algorithm and I found this ...
New
sashaafm
I’m trying to evaluate the best combo/stack for a BEAM Web app. Right now I’m exploring Yaws a bit, after having dealt with Phoenix for a...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
thojanssens1
It would be nice to be able to define a redirect from one route to another from the router.ex file. E.g.: redirect "/", UserController, ...
New
lorenzo
Hey everone! I created a prototype for my app using Nodejs for the api. But the framework I chose wasnt great (in general theresnt any g...
New
RudManusachi
What configs will make sense to put to runtime.exs? – A bit of how I configure apps: I have generic configs in config/config.exs, dev...
New
acrolink
How does the two languages compare when it comes to server side application development? Any experiences or ideas? Thank you.
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
Qqwy
Looking at the stacks that existing large companies have used, WhatsApp internally uses Mnesia to store the messages, while Discord uses ...
New

Other popular topics Top

siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement