Skip to content

Instantly share code, notes, and snippets.

@andrzejsliwa
Created November 9, 2012 14:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrzejsliwa/4045894 to your computer and use it in GitHub Desktop.
Save andrzejsliwa/4045894 to your computer and use it in GitHub Desktop.
A erlang script to change pairs
#!/usr/bin/env escript
my_name() -> "Andrzej Sliwa".
my_email() -> "andrzej.sliwa@my_domain.com".
pairs() ->
[{"an-ar",
[{left, my_name()}, {right, "Artur Kowalski"},
{email, "andrzej+artur@my_domain.com"}]},
{"an-jan",
[{left, my_name()}, {right, "Jan Kowalski"},
{email, "andrzej+jan@my_domain.com"}]}].
main(["help"]) -> usage();
main(["-h"]) -> usage();
main(["/h"]) -> usage();
main([]) ->
switch_git_config(my_name(), my_email());
main([PairName]) ->
Pair = proplists:get_value(PairName, pairs()),
Left = proplists:get_value(left, Pair),
Right = proplists:get_value(right, Pair),
Email = proplists:get_value(email, Pair),
Name = io_lib:format("~s + ~s", [Left, Right]),
switch_git_config(Name, Email),
io:format("Pairing ~s~n", [Name]).
usage() ->
io:format("./pair [name]: pair two people~n"),
io:format("./pair : switch to just me~n").
switch_git_config(Name, Email) ->
cmd("git config user.name '~s'", [Name]),
cmd("git config user.email ~s", [Email]).
cmd(Command, Args) ->
io:format("~s", [os:cmd(io_lib:format(Command, Args))]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment