Skip to content

Instantly share code, notes, and snippets.

@UlisseMini
Last active May 1, 2019 00:18
Show Gist options
  • Save UlisseMini/1cd215722683da9e2c635fc09cb9cf24 to your computer and use it in GitHub Desktop.
Save UlisseMini/1cd215722683da9e2c635fc09cb9cf24 to your computer and use it in GitHub Desktop.
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