Transformation: Fetch from GitHub

Now let’s continue down our data-transformation chain. Having parsed our arguments, we need to transform them by fetching data from GitHub. So we’ll extend our run function to call a process function, passing it the value returned from the parse_args function. We could have written this:

 process(parse_args(argv))

But to understand this code, you have to read it right to left. I prefer to make the chain more explicit using the Elixir pipe operator:

 def​ run(argv) ​do
  argv
  |> parse_args
  |> process
 end

We need two variants of the process function. One handles the case where the user asked for help and parse_args returned :help. The second handles the case where a ...

Get Programming Elixir 1.3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.