Skip to content

Commit

Permalink
Add command line args and usage output
Browse files Browse the repository at this point in the history
  • Loading branch information
qwertymodo committed Mar 17, 2017
1 parent 15d7dcd commit 9e9549b
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions msupcm++/msupcm.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
#include <iostream>
#include "AudioTrackListBuilder.h"
#include "sox_main.h"

#define VERSION_NUMBER 0.2

using namespace msu;

void usage()
{
std::cout << "msupcm v" << VERSION_NUMBER << std::endl << std::endl;
std::cout << "Usage:" << std::endl;
std::cout << "msupcm [tracks.json]" << std::endl;
std::cout << "msupcm -s [sox args]" << std::endl;
std::cout << "msupcm -v" << std::endl;
std::cout << "msupcm ?" << std::endl;
}

int main(int argc, char * argv[])
{
switch (argc)
Expand All @@ -12,22 +25,41 @@ int main(int argc, char * argv[])
break;

case 2:
if (std::string(argv[1]).find_last_of(".") != std::string::npos &&
if (std::string(argv[1]).compare("-v") == 0)
{
std::cout << "msupcm v" << VERSION_NUMBER << std::endl;
break;
}

else if (std::string(argv[1]).compare("?") == 0)
{
usage();
break;
}

else if (std::string(argv[1]).find_last_of(".") != std::string::npos &&
std::string(argv[1]).substr(std::string(argv[1]).find_last_of(".")).compare(".json") == 0)
{
AudioTrackListBuilder(argv[1]).get().render();
}

else
{
usage();
exit(1);
}

break;

default:
if (std::string(argv[1]).compare("-s") == 0)
{
delete argv[1];
argv[1] = new char[4]{ 's','o','x','\0' };

soxmain(--argc, ++argv);
exit(soxmain(--argc, ++argv));
}

usage();
exit(1);
}

Expand Down

0 comments on commit 9e9549b

Please sign in to comment.