diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-04 20:58:01 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-04 20:58:01 +0000 |
commit | 31ea3394a03f010f31d512e753a9f30ca3313e23 (patch) | |
tree | a58433beeac3f70d0c1111841e59ad5bda016485 /tools/skhello.cpp | |
parent | 358f8ff47e4a6f1a43c4cf8d6ee1352b3de3ea43 (diff) |
Convert skhello tool to SkFlags API.
BUG=https://code.google.com/p/skia/issues/detail?id=1094
R=scroggo@google.com
Signed-off-by: Thiago Farina <tfarina@chromium.org>
Review URL: https://chromiumcodereview.appspot.com/12381087
git-svn-id: http://skia.googlecode.com/svn/trunk@7968 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/skhello.cpp')
-rw-r--r-- | tools/skhello.cpp | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/tools/skhello.cpp b/tools/skhello.cpp index 465806f8fa..8cea1d1640 100644 --- a/tools/skhello.cpp +++ b/tools/skhello.cpp @@ -6,40 +6,28 @@ */ #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, "skhello.png", "The filename to write the image."); +DEFINE_string(t, "Hello", "The string to write."); int tool_main(int argc, char** argv); 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; |