Skip to content

Commit

Permalink
add some commmand line options
Browse files Browse the repository at this point in the history
  • Loading branch information
duangsuse committed Jun 3, 2017
1 parent b5e8051 commit f90c09c
Showing 1 changed file with 44 additions and 3 deletions.
47 changes: 44 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,65 @@ void printUsage(int argc, char *argv[])
size_t i = programPath.rfind(pathsep);
string programName = programPath.substr(i+1);
cout << "Usage: " << programName << " <directory> | <pakfile>" << endl;
cout << "NOTE: You can just drag&drop directory or pakfile on scpak executable";
}

void printVersion()
{
const string VERSION = "0.3.1";
cout << "scpak version";
cout << VERSION << endl;
cout << "scpak is a tool for pack/unpack Survivalcraft pak format" << endl;
cout << "visit https://github.com/qnnnnez/scpak for more information" << endl;
}

void printLicense()
{
cout << "The MIT License (MIT) \nCopyright (c) 2017 qnnnnez" << endl;
}

int main(int argc, char *argv[])
{
string path;
bool interactive = false;
if (argc != 2)
if (argc == 1)
{
printUsage(argc, argv);
cout << endl;
cout << "Enter a directory to pack or a .pak file to unpack: ";
cin >> path;
interactive = true;
}
else

else if (argc == 2)
{
path = argv[1];
std::string cmdarg = argv[1];
if (cmdarg == "--help" || cmdarg == "-h")
{
printUsage (argc, argv);
return 0;
}
else if (cmdarg == "--version" || cmdarg == "-v")
{
printVersion ();
return 0;
}
else if (cmdarg == "--licence" || cmdarg == "--license")
{
printLicense ();
return 0;
}
else
{
path = argv[1];
}
}
else
{
cerr << "error: unrecognized command line option" <<endl;
return 1;
}


if (!pathExists(path.c_str()))
{
Expand Down

0 comments on commit f90c09c

Please sign in to comment.