chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 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 | |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 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 | |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 19 | int main(int argc, char *argv[]) { |
| 20 | QApplication a(argc, argv); |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 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 | |
robertphillips@google.com | e219baf | 2013-01-28 19:25:43 +0000 | [diff] [blame] | 32 | SkString commandName(iter->toAscii().data()); |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 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()) { |
robertphillips@google.com | e219baf | 2013-01-28 19:25:43 +0000 | [diff] [blame] | 40 | input = SkString(iter->toAscii().data()); |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 41 | } else { |
| 42 | usage(commandName.c_str()); |
| 43 | return -1; |
| 44 | } |
| 45 | } |
| 46 | |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 47 | SkDebuggerGUI w; |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 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 | |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 57 | w.show(); |
| 58 | return a.exec(); |
| 59 | } |