Last active
May 1, 2019 00:18
-
-
Save UlisseMini/1cd215722683da9e2c635fc09cb9cf24 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 Cli do | |
@moduledoc " Cli to check if a gitlab username is taken" | |
@doc " The entry point for the program" | |
def main([]) do | |
IO.puts "Usage: #{:escript.script_name()} <username>" | |
end | |
def main([user]) do | |
Application.ensure_all_started(:inets) | |
Application.ensure_all_started(:ssl) | |
exists(user) |> IO.puts | |
end | |
defp exists(user) do | |
{:ok, {{_proto, _code, _status}, _headers, body}} = | |
:httpc.request(:get, {'https://gitlab.com/users/#{user}/exists', []}, [], []) | |
body =~ 'true' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment