Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(884)

Unified Diff: tools/skhello.cpp

Issue 12381087: Convert skhello tool to SkFlags API. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: review Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/tools.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/skhello.cpp
diff --git a/tools/skhello.cpp b/tools/skhello.cpp
index 465806f8faf4cfd13f8688da958091661c844719..8cea1d16403902b0d40925de05e832a7c870589f 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;
« no previous file with comments | « gyp/tools.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698