From 9e9549be2cbc5d68c16d3845f7e9301db6b540cd Mon Sep 17 00:00:00 2001 From: qwertymodo Date: Thu, 16 Mar 2017 17:00:32 -0700 Subject: [PATCH] Add command line args and usage output --- msupcm++/msupcm.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/msupcm++/msupcm.cpp b/msupcm++/msupcm.cpp index 8db6cbf..129f2f1 100644 --- a/msupcm++/msupcm.cpp +++ b/msupcm++/msupcm.cpp @@ -1,8 +1,21 @@ +#include #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) @@ -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); }