-
-
Save andrzejsliwa/4045894 to your computer and use it in GitHub Desktop.
A erlang script to change pairs
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
#!/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