Last active
October 8, 2018 18:06
-
-
Save ndugger/9ce623bcc41be9888264e096c51061ee 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
| # include <functional> | |
| # include <iostream> | |
| # include <map> | |
| # include <string> | |
| # include "git2/global.h" | |
| # include "grok/commands/help.h" | |
| # include "grok/commands/make.h" | |
| # include "grok/commands/sync.h" | |
| # include "grok/commands/update.h" | |
| # include "grok/commands/use.h" | |
| # include "grok/utilities/unrecognized.h" | |
| using namespace std; | |
| using namespace grok::commands; | |
| using namespace grok::utilities; | |
| map<string, function<int(string[])>> commands = { | |
| { "help", help }, | |
| { "make", make }, | |
| { "sync", sync }, | |
| { "update", update }, | |
| { "use", use } | |
| }; | |
| int main (int size, char* arguments[]) { | |
| string command_name = arguments[ 1 ]; | |
| string command_arguments[ size - 2 ]; | |
| for (int i = 0; i < size - 2; ++i) { | |
| command_arguments[ i ] = arguments[ i + 2 ]; | |
| } | |
| git_libgit2_init(); | |
| if (size < 2) { | |
| return help(command_arguments); | |
| } | |
| else if (commands[ command_name ] == nullptr) { | |
| return unrecognized(command_name); | |
| } | |
| else { | |
| return commands[ command_name ](command_arguments); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment