Skip to content

Instantly share code, notes, and snippets.

@ngw

ngw/optpars.ex Secret

Created July 9, 2016 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngw/cb9120d421b56894b5f159c84d08d747 to your computer and use it in GitHub Desktop.
Save ngw/cb9120d421b56894b5f159c84d08d747 to your computer and use it in GitHub Desktop.
def parse_args(argv) do
parse = OptionParser.parse(argv, switches: [ help: :boolean,
from: :string ,
to: :string],
aliases: [ h: :help,
f: :from,
t: :to ])
case parse do
{ [ help: true ], _, _ } -> :help
{ [ to: to ], _, _ } -> [ from: '.' , to: to ]
{ [ from: from, to: to ], _, _ } -> [ from: from, to: to ]
_ -> :help
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment