blob: f749911a982a8185fdd0071717b35e17b5ab100d [file] [log] [blame]
chudy@google.com607357f2012-08-07 16:12:23 +00001
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
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000012static 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
chudy@google.com607357f2012-08-07 16:12:23 +000019int main(int argc, char *argv[]) {
20 QApplication a(argc, argv);
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000021
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
robertphillips@google.come219baf2013-01-28 19:25:43 +000032 SkString commandName(iter->toAscii().data());
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000033 ++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()) {
robertphillips@google.come219baf2013-01-28 19:25:43 +000040 input = SkString(iter->toAscii().data());
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000041 } else {
42 usage(commandName.c_str());
43 return -1;
44 }
45 }
46
chudy@google.com607357f2012-08-07 16:12:23 +000047 SkDebuggerGUI w;
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000048
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
chudy@google.com607357f2012-08-07 16:12:23 +000057 w.show();
58 return a.exec();
59}