{"action":"created","comment":{"url":"https://api.github.com/repos/rawdamedia/quoil/pulls/comments/35058410","id":35058410,"diff_hunk":"@@ -0,0 +1,61 @@\n+defmodule Quoil.CLI do\n+  @moduledoc \"\"\"\n+  Command line interface for the quoil function  \n+    -> parsing the arguments\n+    -> running the ping command  \n+    -> interpreting the results  \n+    -> logging\n+    \"\"\"\n+\n+  def main(argv) do\n+    argv\n+    |> Quoil.ArgsProcessor.parse_args\n+    |> terminate_early?\n+    |> run_ping\n+    |> Quoil.ParseResults.parse_result\n+    |> Quoil.LogResults.write_log\n+    |> Quoil.Repeat.requested?\n+\n+  end\n+\n+\n+  def terminate_early?(:help) do\n+    IO.puts \"\"\"\n+    usage: quoil [-h | --help]\n+    quoil [--interval sec] [--number nr] [--repeat nr [--wait min]] <ip_to_ping> [log_file_name]\n+    \n+    all values supplied must be positive integers\n+\n+    For more information see: https://github.com/rawdamedia/quoil\n+    \"\"\"\n+    System.halt(0)\n+  end\n+  def terminate_early?(:error) do\n+    IO.puts \"ERROR: There was an error with the command line switches.\"","path":"lib/quoil/cli.ex","position":34,"original_position":34,"commit_id":"7f09e03bca44b8e37753adfab3f858129fd0bc71","original_commit_id":"7f09e03bca44b8e37753adfab3f858129fd0bc71","user":{"login":"madlep","id":27223,"avatar_url":"https://avatars.githubusercontent.com/u/27223?v=3","gravatar_id":"","url":"https://api.github.com/users/madlep","html_url":"https://github.com/madlep","followers_url":"https://api.github.com/users/madlep/followers","following_url":"https://api.github.com/users/madlep/following{/other_user}","gists_url":"https://api.github.com/users/madlep/gists{/gist_id}","starred_url":"https://api.github.com/users/madlep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madlep/subscriptions","organizations_url":"https://api.github.com/users/madlep/orgs","repos_url":"https://api.github.com/users/madlep/repos","events_url":"https://api.github.com/users/madlep/events{/privacy}","received_events_url":"https://api.github.com/users/madlep/received_events","type":"User","site_admin":false},"body":"Using an error monad library means your functions don't see the `:ok` or `:error` element in the tuple, and just the payload. The monad effectively wraps metadata around the actual data you are working with, and handles wrapping, and unwrapping it.\r\n\r\nIn the case of an error, it **doesn't** call subsequent functions. It just returns the error straight away and bypasses them.\r\n\r\nIt's a more elegant way of writing deep nested logic to handle errors at any point.\r\n\r\nSo rather than writing\r\n\r\n```elixir\r\ncase do_a_thing(data) do\r\n  {:ok, payload} ->\r\n    case do_another_thing(payload) do\r\n      {:ok, another_payload} ->\r\n        case do_yet_another_thing(another_payload) do\r\n          {:ok, yet_another_payload} -> yet_another_payload\r\n          {:error, error} -> handle_error(error)\r\n        end\r\n      {:error, error} -> handle_error(error)\r\n    end\r\n  {:error, error} -> handle error\r\nend\r\n```\r\n\r\nyou can do\r\n```elixir\r\nresult = Error.p do\r\n  Error.return(data)\r\n  |> do_a_thing\r\n  |> do_another_thing\r\n  |> do_yet_another_thing\r\nend\r\n\r\ncase result do\r\n  {:error, error} -> handle_error(error)\r\n  {:ok, value} -> value\r\nend\r\n```\r\n\r\nIt's less commonly used in Elixir than in something like Haskell, but it makes code like this much cleaner and easier to work with","created_at":"2015-07-21T00:04:02Z","updated_at":"2015-07-21T00:04:02Z","html_url":"https://github.com/rawdamedia/quoil/pull/3#discussion_r35058410","pull_request_url":"https://api.github.com/repos/rawdamedia/quoil/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/rawdamedia/quoil/pulls/comments/35058410"},"html":{"href":"https://github.com/rawdamedia/quoil/pull/3#discussion_r35058410"},"pull_request":{"href":"https://api.github.com/repos/rawdamedia/quoil/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/rawdamedia/quoil/pulls/3","id":40290247,"html_url":"https://github.com/rawdamedia/quoil/pull/3","diff_url":"https://github.com/rawdamedia/quoil/pull/3.diff","patch_url":"https://github.com/rawdamedia/quoil/pull/3.patch","issue_url":"https://api.github.com/repos/rawdamedia/quoil/issues/3","number":3,"state":"open","locked":false,"title":"[DON'T MERGE] Dummy pull request to allow feedback on what's currently in master","user":{"login":"madlep","id":27223,"avatar_url":"https://avatars.githubusercontent.com/u/27223?v=3","gravatar_id":"","url":"https://api.github.com/users/madlep","html_url":"https://github.com/madlep","followers_url":"https://api.github.com/users/madlep/followers","following_url":"https://api.github.com/users/madlep/following{/other_user}","gists_url":"https://api.github.com/users/madlep/gists{/gist_id}","starred_url":"https://api.github.com/users/madlep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madlep/subscriptions","organizations_url":"https://api.github.com/users/madlep/orgs","repos_url":"https://api.github.com/users/madlep/repos","events_url":"https://api.github.com/users/madlep/events{/privacy}","received_events_url":"https://api.github.com/users/madlep/received_events","type":"User","site_admin":false},"body":"Created this by running\r\n\r\n```sh\r\ngit branch madlep_feedback 2bc787f10e8bd7d8e533230f9ef9d5b1e18d1f40\r\ngit checkout madlep_feedback\r\ngit push origin madlep_feedback\r\n```\r\n\r\nThis resets this branch back to the start of the project.\r\n\r\nThen created pull request to merge master into this branch.\r\n\r\nSo it shows the full project as being the diff that will be applied, and feedback can be done on the whole thing.","created_at":"2015-07-18T10:19:31Z","updated_at":"2015-07-21T00:04:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f826244bdb2131522305244fccd4ee5557ec4169","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rawdamedia/quoil/pulls/3/commits","review_comments_url":"https://api.github.com/repos/rawdamedia/quoil/pulls/3/comments","review_comment_url":"https://api.github.com/repos/rawdamedia/quoil/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rawdamedia/quoil/issues/3/comments","statuses_url":"https://api.github.com/repos/rawdamedia/quoil/statuses/7f09e03bca44b8e37753adfab3f858129fd0bc71","head":{"label":"rawdamedia:master","ref":"master","sha":"7f09e03bca44b8e37753adfab3f858129fd0bc71","user":{"login":"rawdamedia","id":4233372,"avatar_url":"https://avatars.githubusercontent.com/u/4233372?v=3","gravatar_id":"","url":"https://api.github.com/users/rawdamedia","html_url":"https://github.com/rawdamedia","followers_url":"https://api.github.com/users/rawdamedia/followers","following_url":"https://api.github.com/users/rawdamedia/following{/other_user}","gists_url":"https://api.github.com/users/rawdamedia/gists{/gist_id}","starred_url":"https://api.github.com/users/rawdamedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rawdamedia/subscriptions","organizations_url":"https://api.github.com/users/rawdamedia/orgs","repos_url":"https://api.github.com/users/rawdamedia/repos","events_url":"https://api.github.com/users/rawdamedia/events{/privacy}","received_events_url":"https://api.github.com/users/rawdamedia/received_events","type":"User","site_admin":false},"repo":{"id":35825604,"name":"quoil","full_name":"rawdamedia/quoil","owner":{"login":"rawdamedia","id":4233372,"avatar_url":"https://avatars.githubusercontent.com/u/4233372?v=3","gravatar_id":"","url":"https://api.github.com/users/rawdamedia","html_url":"https://github.com/rawdamedia","followers_url":"https://api.github.com/users/rawdamedia/followers","following_url":"https://api.github.com/users/rawdamedia/following{/other_user}","gists_url":"https://api.github.com/users/rawdamedia/gists{/gist_id}","starred_url":"https://api.github.com/users/rawdamedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rawdamedia/subscriptions","organizations_url":"https://api.github.com/users/rawdamedia/orgs","repos_url":"https://api.github.com/users/rawdamedia/repos","events_url":"https://api.github.com/users/rawdamedia/events{/privacy}","received_events_url":"https://api.github.com/users/rawdamedia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rawdamedia/quoil","description":"QUality Of Internet Link","fork":false,"url":"https://api.github.com/repos/rawdamedia/quoil","forks_url":"https://api.github.com/repos/rawdamedia/quoil/forks","keys_url":"https://api.github.com/repos/rawdamedia/quoil/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rawdamedia/quoil/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rawdamedia/quoil/teams","hooks_url":"https://api.github.com/repos/rawdamedia/quoil/hooks","issue_events_url":"https://api.github.com/repos/rawdamedia/quoil/issues/events{/number}","events_url":"https://api.github.com/repos/rawdamedia/quoil/events","assignees_url":"https://api.github.com/repos/rawdamedia/quoil/assignees{/user}","branches_url":"https://api.github.com/repos/rawdamedia/quoil/branches{/branch}","tags_url":"https://api.github.com/repos/rawdamedia/quoil/tags","blobs_url":"https://api.github.com/repos/rawdamedia/quoil/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rawdamedia/quoil/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rawdamedia/quoil/git/refs{/sha}","trees_url":"https://api.github.com/repos/rawdamedia/quoil/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rawdamedia/quoil/statuses/{sha}","languages_url":"https://api.github.com/repos/rawdamedia/quoil/languages","stargazers_url":"https://api.github.com/repos/rawdamedia/quoil/stargazers","contributors_url":"https://api.github.com/repos/rawdamedia/quoil/contributors","subscribers_url":"https://api.github.com/repos/rawdamedia/quoil/subscribers","subscription_url":"https://api.github.com/repos/rawdamedia/quoil/subscription","commits_url":"https://api.github.com/repos/rawdamedia/quoil/commits{/sha}","git_commits_url":"https://api.github.com/repos/rawdamedia/quoil/git/commits{/sha}","comments_url":"https://api.github.com/repos/rawdamedia/quoil/comments{/number}","issue_comment_url":"https://api.github.com/repos/rawdamedia/quoil/issues/comments{/number}","contents_url":"https://api.github.com/repos/rawdamedia/quoil/contents/{+path}","compare_url":"https://api.github.com/repos/rawdamedia/quoil/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rawdamedia/quoil/merges","archive_url":"https://api.github.com/repos/rawdamedia/quoil/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rawdamedia/quoil/downloads","issues_url":"https://api.github.com/repos/rawdamedia/quoil/issues{/number}","pulls_url":"https://api.github.com/repos/rawdamedia/quoil/pulls{/number}","milestones_url":"https://api.github.com/repos/rawdamedia/quoil/milestones{/number}","notifications_url":"https://api.github.com/repos/rawdamedia/quoil/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rawdamedia/quoil/labels{/name}","releases_url":"https://api.github.com/repos/rawdamedia/quoil/releases{/id}","created_at":"2015-05-18T15:21:54Z","updated_at":"2015-07-17T13:42:12Z","pushed_at":"2015-07-18T10:19:32Z","git_url":"git://github.com/rawdamedia/quoil.git","ssh_url":"git@github.com:rawdamedia/quoil.git","clone_url":"https://github.com/rawdamedia/quoil.git","svn_url":"https://github.com/rawdamedia/quoil","homepage":null,"size":3580,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"rawdamedia:madlep_feedback","ref":"madlep_feedback","sha":"2bc787f10e8bd7d8e533230f9ef9d5b1e18d1f40","user":{"login":"rawdamedia","id":4233372,"avatar_url":"https://avatars.githubusercontent.com/u/4233372?v=3","gravatar_id":"","url":"https://api.github.com/users/rawdamedia","html_url":"https://github.com/rawdamedia","followers_url":"https://api.github.com/users/rawdamedia/followers","following_url":"https://api.github.com/users/rawdamedia/following{/other_user}","gists_url":"https://api.github.com/users/rawdamedia/gists{/gist_id}","starred_url":"https://api.github.com/users/rawdamedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rawdamedia/subscriptions","organizations_url":"https://api.github.com/users/rawdamedia/orgs","repos_url":"https://api.github.com/users/rawdamedia/repos","events_url":"https://api.github.com/users/rawdamedia/events{/privacy}","received_events_url":"https://api.github.com/users/rawdamedia/received_events","type":"User","site_admin":false},"repo":{"id":35825604,"name":"quoil","full_name":"rawdamedia/quoil","owner":{"login":"rawdamedia","id":4233372,"avatar_url":"https://avatars.githubusercontent.com/u/4233372?v=3","gravatar_id":"","url":"https://api.github.com/users/rawdamedia","html_url":"https://github.com/rawdamedia","followers_url":"https://api.github.com/users/rawdamedia/followers","following_url":"https://api.github.com/users/rawdamedia/following{/other_user}","gists_url":"https://api.github.com/users/rawdamedia/gists{/gist_id}","starred_url":"https://api.github.com/users/rawdamedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rawdamedia/subscriptions","organizations_url":"https://api.github.com/users/rawdamedia/orgs","repos_url":"https://api.github.com/users/rawdamedia/repos","events_url":"https://api.github.com/users/rawdamedia/events{/privacy}","received_events_url":"https://api.github.com/users/rawdamedia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rawdamedia/quoil","description":"QUality Of Internet Link","fork":false,"url":"https://api.github.com/repos/rawdamedia/quoil","forks_url":"https://api.github.com/repos/rawdamedia/quoil/forks","keys_url":"https://api.github.com/repos/rawdamedia/quoil/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rawdamedia/quoil/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rawdamedia/quoil/teams","hooks_url":"https://api.github.com/repos/rawdamedia/quoil/hooks","issue_events_url":"https://api.github.com/repos/rawdamedia/quoil/issues/events{/number}","events_url":"https://api.github.com/repos/rawdamedia/quoil/events","assignees_url":"https://api.github.com/repos/rawdamedia/quoil/assignees{/user}","branches_url":"https://api.github.com/repos/rawdamedia/quoil/branches{/branch}","tags_url":"https://api.github.com/repos/rawdamedia/quoil/tags","blobs_url":"https://api.github.com/repos/rawdamedia/quoil/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rawdamedia/quoil/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rawdamedia/quoil/git/refs{/sha}","trees_url":"https://api.github.com/repos/rawdamedia/quoil/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rawdamedia/quoil/statuses/{sha}","languages_url":"https://api.github.com/repos/rawdamedia/quoil/languages","stargazers_url":"https://api.github.com/repos/rawdamedia/quoil/stargazers","contributors_url":"https://api.github.com/repos/rawdamedia/quoil/contributors","subscribers_url":"https://api.github.com/repos/rawdamedia/quoil/subscribers","subscription_url":"https://api.github.com/repos/rawdamedia/quoil/subscription","commits_url":"https://api.github.com/repos/rawdamedia/quoil/commits{/sha}","git_commits_url":"https://api.github.com/repos/rawdamedia/quoil/git/commits{/sha}","comments_url":"https://api.github.com/repos/rawdamedia/quoil/comments{/number}","issue_comment_url":"https://api.github.com/repos/rawdamedia/quoil/issues/comments{/number}","contents_url":"https://api.github.com/repos/rawdamedia/quoil/contents/{+path}","compare_url":"https://api.github.com/repos/rawdamedia/quoil/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rawdamedia/quoil/merges","archive_url":"https://api.github.com/repos/rawdamedia/quoil/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rawdamedia/quoil/downloads","issues_url":"https://api.github.com/repos/rawdamedia/quoil/issues{/number}","pulls_url":"https://api.github.com/repos/rawdamedia/quoil/pulls{/number}","milestones_url":"https://api.github.com/repos/rawdamedia/quoil/milestones{/number}","notifications_url":"https://api.github.com/repos/rawdamedia/quoil/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rawdamedia/quoil/labels{/name}","releases_url":"https://api.github.com/repos/rawdamedia/quoil/releases{/id}","created_at":"2015-05-18T15:21:54Z","updated_at":"2015-07-17T13:42:12Z","pushed_at":"2015-07-18T10:19:32Z","git_url":"git://github.com/rawdamedia/quoil.git","ssh_url":"git@github.com:rawdamedia/quoil.git","clone_url":"https://github.com/rawdamedia/quoil.git","svn_url":"https://github.com/rawdamedia/quoil","homepage":null,"size":3580,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rawdamedia/quoil/pulls/3"},"html":{"href":"https://github.com/rawdamedia/quoil/pull/3"},"issue":{"href":"https://api.github.com/repos/rawdamedia/quoil/issues/3"},"comments":{"href":"https://api.github.com/repos/rawdamedia/quoil/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/rawdamedia/quoil/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/rawdamedia/quoil/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rawdamedia/quoil/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/rawdamedia/quoil/statuses/7f09e03bca44b8e37753adfab3f858129fd0bc71"}}}}