diff options
author | Cleverking2003 <30466983+Cleverking2003@users.noreply.github.com> | 2020-06-19 00:02:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-19 00:02:21 +0300 |
commit | a455bac566535ec559aac9164e05781093653057 (patch) | |
tree | d7adbe4bb91cce929d5fcb1bb26d992474639afa /tools/knarc/Source.cpp | |
parent | f20e222730ad06a967eb1003f38f100fa81fed43 (diff) | |
parent | c2ca3c0c4fc49a19554c202e45a990c61752e15d (diff) |
Merge pull request #171 from PikalaxALT/pikalax_work
KNARC: Add handling of .knarcignore, .knarckeep; fix up cli; implement o2narc for poketool/personal/*.narc
Diffstat (limited to 'tools/knarc/Source.cpp')
-rw-r--r-- | tools/knarc/Source.cpp | 61 |
1 files changed, 49 insertions, 12 deletions
diff --git a/tools/knarc/Source.cpp b/tools/knarc/Source.cpp index 51bb5320..21020891 100644 --- a/tools/knarc/Source.cpp +++ b/tools/knarc/Source.cpp @@ -6,6 +6,9 @@ using namespace std; +bool debug = false; +bool pack_no_fnt = true; + void PrintError(NarcError error) { switch (error) @@ -27,20 +30,20 @@ void PrintError(NarcError error) } } +static inline void usage() { + cout << "OVERVIEW: Knarc" << endl << endl; + cout << "USAGE: knarc [options] -d DIRECTORY [-p TARGET | -u SOURCE]" << endl << endl; + cout << "OPTIONS:" << endl; + cout << "\t-d DIRECTORY\tDirectory to pack from/unpack to" << endl; + cout << "\t-p TARGET\tPack to the target NARC" << endl; + cout << "\t-u SOURCE\tUnpack from the source NARC" << endl; + cout << "\t-n\tBuild the filename table (default: discards filenames)" << endl; + cout << "\t-D/--debug\tPrint additional debug messages" << endl; + cout << "\t-h/--help\tPrint this message and exit" << endl; +} + int main(int argc, char* argv[]) { - if (argc != 5) - { - cout << "OVERVIEW: Knarc" << endl << endl; - cout << "USAGE: knarc [options] <inputs>" << endl << endl; - cout << "OPTIONS:" << endl; - cout << "\t-d\tDirectory to pack from/unpack to" << endl; - cout << "\t-p\tPack" << endl; - cout << "\t-u\tUnpack" << endl; - - return 1; - } - string directory = ""; string fileName = ""; bool pack = false; @@ -56,6 +59,10 @@ int main(int argc, char* argv[]) return 1; } + if (!directory.empty()) { + cerr << "ERROR: Multiple directories specified" << endl; + return 1; + } directory = argv[++i]; } else if (!strcmp(argv[i], "-p")) @@ -67,6 +74,10 @@ int main(int argc, char* argv[]) return 1; } + if (!fileName.empty()) { + cerr << "ERROR: Multiple files specified" << endl; + return 1; + } fileName = argv[++i]; pack = true; } @@ -79,10 +90,36 @@ int main(int argc, char* argv[]) return 1; } + if (!fileName.empty()) { + cerr << "ERROR: Multiple files specified" << endl; + return 1; + } fileName = argv[++i]; + } else if (!strcmp(argv[i], "-D") || !strcmp(argv[i], "--debug")) { + debug = true; + } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { + usage(); + return 0; + } + else if (!strcmp(argv[i], "-n")) { + pack_no_fnt = false; + } + else { + usage(); + cerr << "ERROR: Unrecognized argument: " << argv[i] << endl; + return 1; } } + if (fileName.empty()) { + cerr << "ERROR: Missing -u or -p" << endl; + return 1; + } + if (directory.empty()) { + cerr << "ERROR: Missing -d" << endl; + return 1; + } + Narc narc; if (pack) |