1 2 /* 3 * Copyright 2012 Google Inc. 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9 #include "SkDebuggerGUI.h" 10 #include <QApplication> 11 12 static void usage(const char * argv0) { 13 SkDebugf("%s <input> \n", argv0); 14 SkDebugf(" [--help|-h]: show this help message\n"); 15 SkDebugf("\n\n"); 16 SkDebugf(" input: Either a directory or a single .skp file.\n"); 17 } 18 19 int main(int argc, char *argv[]) { 20 QApplication a(argc, argv); 21 22 QStringList argList = a.arguments(); 23 24 if (argList.count() <= 0) { 25 return -1; // should at least have command name 26 } 27 28 SkString input; 29 30 QStringList::const_iterator iter = argList.begin(); 31 32 SkString commandName(iter->toAscii().data()); 33 ++iter; // skip the command name 34 35 for ( ; iter != argList.end(); ++iter) { 36 if (0 == iter->compare("--help") || 0 == iter->compare("-h")) { 37 usage(commandName.c_str()); 38 return -1; 39 } else if (input.isEmpty()) { 40 input = SkString(iter->toAscii().data()); 41 } else { 42 usage(commandName.c_str()); 43 return -1; 44 } 45 } 46 47 SkDebuggerGUI w; 48 49 if (!input.isEmpty()) { 50 if (SkStrEndsWith(input.c_str(), ".skp")) { 51 w.openFile(input.c_str()); 52 } else { 53 w.setupDirectoryWidget(input.c_str()); 54 } 55 } 56 57 w.show(); 58 return a.exec(); 59 } 60