Chromium Code Reviews| Index: tools/skhello.cpp |
| diff --git a/tools/skhello.cpp b/tools/skhello.cpp |
| index 465806f8faf4cfd13f8688da958091661c844719..d38f6d6bb2fe96adedcb4601cf0b975536e30889 100644 |
| --- a/tools/skhello.cpp |
| +++ b/tools/skhello.cpp |
| @@ -6,40 +6,27 @@ |
| */ |
| #include "SkCanvas.h" |
| +#include "SkFlags.h" |
| #include "SkGraphics.h" |
| #include "SkImageEncoder.h" |
| #include "SkString.h" |
| -static void show_help() { |
| - SkDebugf("usage: skhello [-o out-dir] [-t 'hello']\n default output: skhello.png\n"); |
| -} |
| +DEFINE_string(o, "", "The filename to write the image."); |
|
scroggo
2013/03/04 20:40:31
Why not set "skhello.png" as the default value?
tfarina
2013/03/04 20:46:10
Done.
|
| +DEFINE_string(t, "", "The string to write."); |
|
scroggo
2013/03/04 20:40:31
Why not set "Hello" as the default value?
tfarina
2013/03/04 20:46:10
Done.
|
| -int tool_main(int argc, char** argv); |
|
scroggo
2013/03/04 20:40:31
I think this prevents a warning on certain platfor
tfarina
2013/03/04 20:46:10
Done.
|
| int tool_main(int argc, char** argv) { |
| + SkFlags::SetUsage(""); |
| + SkFlags::ParseCommandLine(argc, argv); |
| + |
| SkAutoGraphics ag; |
| SkString path("skhello.png"); |
| SkString text("Hello"); |
| - for (int i = 1; i < argc; i++) { |
| - if (!strcmp(argv[i], "--help")) { |
| - show_help(); |
| - return 0; |
| - } |
| - if (!strcmp(argv[i], "-o")) { |
| - if (i == argc-1) { |
| - SkDebugf("ERROR: -o needs a following filename\n"); |
| - return -1; |
| - } |
| - path.set(argv[i+1]); |
| - i += 1; // skip the out dir name |
| - } else if (!strcmp(argv[i], "-t")) { |
| - if (i == argc-1) { |
| - SkDebugf("ERROR: -t needs a following string\n"); |
| - return -1; |
| - } |
| - text.set(argv[i+1]); |
| - i += 1; // skip the text string |
| - } |
| + if (!FLAGS_o.isEmpty()) { |
| + path.set(FLAGS_o[0]); |
| + } |
| + if (!FLAGS_t.isEmpty()) { |
| + text.set(FLAGS_t[0]); |
| } |
| SkPaint paint; |