Created
June 22, 2014 17:55
-
-
Save sasa1977/78fa75915cc05a1b01a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Test do | |
| @proto_version "1.0" | |
| def process_options(opts) do | |
| ["-proto", @proto_version] ++ log_opt ++ process_input_options(opts) | |
| end | |
| defp log_opt do | |
| case :application.get_env(:porcelain, :goon_driver_log) do | |
| :undefined -> [] | |
| {:ok, val} -> ["-log", val] | |
| end | |
| end | |
| defp process_input_options(opts) do | |
| Enum.reduce(opts, [], &(process_option(&1) ++ &2)) | |
| end | |
| defp process_option({:in, true}), do: ["-in"] | |
| defp process_option({:err, :out}), do: ["-err", "out"] | |
| defp process_option({:err, :err}), do: ["-err", "err"] | |
| defp process_option({:dir, dir}), do: ["-dir", "dir"] | |
| defp process_option(_), do: [] | |
| end | |
| Test.process_options(in: true, err: :out, dir: "dir") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment