Skip to content

Commit

Permalink
wpm + wpmPackageInit support running both local & global mode
Browse files Browse the repository at this point in the history
  • Loading branch information
prophecy committed Jul 5, 2017
1 parent 4940c94 commit f826d6a
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/wpm/wpm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,20 @@ void showWelcomeMessage();

// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// Constants
const string VERSION = "0.0.0.1";
const string VERSION = "0.0.1.0";
const string WONDER_MODULE = "wonder_modules";
const string WONDER_TEMP_MODULE = "wonder_modules/tmp";
const string WONDER_CONF = "wonderconf.json";

const string MODE_LOCAL = "MODE_LOCAL";
const string MODE_GLOBAL = "MODE_GLOBAL";

// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// Shared vars

map<string, void*> commandMap;
map<string, string> descMap;
string mode;

void addCommand(string name, void* commandFunctionPointer, string desc) {

Expand All @@ -72,6 +76,12 @@ int main(int argc, const char * argv[]) {
[2][And more] command params
***********************************************/

// Set mode from command
if (string(argv[0]).compare("wpm") == 0)
mode = MODE_GLOBAL;
else
mode = MODE_LOCAL;

// Show info if hitting wpm without any command
if (argc <= 1) {

Expand Down Expand Up @@ -307,9 +317,19 @@ string run(int argc, const char* argv[]) {

string packageName = argv[2];

// Todo: Execute package commands
string executingCommand = string("./") + string(WONDER_MODULE) + "/" +
packageName + string("/init ") + packageName + string(" ") + "./" + string(WONDER_CONF);
// Execute package commands
string wpmPackageInit = "";

if (mode.compare(MODE_LOCAL) == 0)
wpmPackageInit = "./wpmPackageInit";
else if (mode.compare(MODE_GLOBAL) == 0)
wpmPackageInit = "wpmPackageInit";
else {
cout << "wpmPackageInit has error! mode " << mode << " does NOT support!" << endl;
}

string executingCommand = wpmPackageInit + string(" ") +
packageName + string(" ") + "./" + string(WONDER_CONF);

cout << "run command: " << executingCommand << endl;

Expand Down

0 comments on commit f826d6a

Please sign in to comment.