]> git.cworth.org Git - apitrace/blobdiff - cli/cli_dump.cpp
Add "apitrace diff-images" command
[apitrace] / cli / cli_dump.cpp
index fcc08f74bc9bdc430661fe7b3b25d73d7dfb1b2f..5baa5ae88b44b11378f9360dc6201e8f00135488 100644 (file)
@@ -37,25 +37,26 @@ enum ColorOption {
 
 static ColorOption color = COLOR_OPTION_AUTO;
 
-void
-apitrace_dump_usage(const char *argv0)
+static const char *synopsis = "Dump given trace(s) to standard output.";
+
+static void
+usage(void)
 {
-    std::cout << argv0 << " [OPTIONS] <trace-file>..."
-        "\n\n\t"
-        APITRACE_DUMP_SYNOPSIS
-        "\n\n\t"
-        "Supports the following options:\n\t"
-       "\t--color=<WHEN>\n\t"
-       "\t--colour=<WHEN>     Colored syntax highlighting\n\t"
-       "\t                    WHEN is 'auto', 'always', or 'never'\n";
+    std::cout
+        << "usage: apitrace dump [OPTIONS] <trace-file>...\n"
+        << synopsis << "\n"
+        "\n"
+        "    --color=<WHEN>\n"
+        "    --colour=<WHEN>     Colored syntax highlighting\n"
+        "                        WHEN is 'auto', 'always', or 'never'\n";
 }
 
-int
-apitrace_dump_command(int argc, char *argv[], int first_arg_command)
+static int
+command(int argc, char *argv[])
 {
     int i;
 
-    for (i = first_arg_command; i < argc; ++i) {
+    for (i = 0; i < argc; ++i) {
         const char *arg = argv[i];
 
         if (arg[0] != '-') {
@@ -64,6 +65,9 @@ apitrace_dump_command(int argc, char *argv[], int first_arg_command)
 
         if (!strcmp(arg, "--")) {
             break;
+        } else if (!strcmp(arg, "--help")) {
+            usage();
+            return 0;
         } else if (!strcmp(arg, "--color=auto") ||
                    !strcmp(arg, "--colour=auto")) {
             color = COLOR_OPTION_AUTO;
@@ -109,3 +113,10 @@ apitrace_dump_command(int argc, char *argv[], int first_arg_command)
 
     return 0;
 }
+
+const Command dump_command = {
+    "dump",
+    synopsis,
+    usage,
+    command
+};