[waffle] [PATCH 4/4] wflinfo: implement short options for common parameters

Jordan Justen jordan.l.justen at intel.com
Mon Jan 20 14:27:54 PST 2014


-p for --platform
-a for --api
-V for --version
-v for --verbose

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 man/wflinfo.1.xml   |  6 ++++++
 src/utils/wflinfo.c | 20 +++++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/man/wflinfo.1.xml b/man/wflinfo.1.xml
index 958e169..1f81e73 100644
--- a/man/wflinfo.1.xml
+++ b/man/wflinfo.1.xml
@@ -64,6 +64,7 @@
 
     <variablelist>
       <varlistentry>
+        <term><option>-p</option> <replaceable class="parameter">platform</replaceable></term>
         <term><option>--platform=<replaceable class="parameter">platform</replaceable></option></term>
         <listitem>
           <para>
@@ -81,6 +82,7 @@
         </listitem>
       </varlistentry>
       <varlistentry>
+        <term><option>-a</option> <replaceable class="parameter">api</replaceable></term>
         <term><option>--api=<replaceable class="parameter">api</replaceable></option></term>
         <listitem>
           <para>
@@ -103,6 +105,7 @@
     <title>Options</title>
     <variablelist>
       <varlistentry>
+        <term><option>-V</option> <replaceable class="parameter">MAJOR.MINOR</replaceable></term>
         <term><option>--version=<replaceable class="parameter">MAJOR.MINOR</replaceable></option></term>
         <listitem>
           <para>
@@ -119,6 +122,7 @@
         </listitem>
       </varlistentry>
       <varlistentry>
+        <term><option>-v</option></term>
         <term><option>--verbose</option></term>
         <listitem>
           <para>
@@ -153,6 +157,8 @@
         <member>wflinfo --platform=glx --api=gl</member>
         <member>wflinfo --platform=x11_egl --api=gl --version=3.2 --profile=core</member>
         <member>wflinfo --platform=wayland --api=gles3</member>
+        <member>wflinfo --platform=gbm --api=gl --version=3.2 --verbose</member>
+        <member>wflinfo -p gbm -a gl -V 3.2 -v</member>
       </simplelist>
     </para>
 
diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c
index 34eeb78..1a458ed 100644
--- a/src/utils/wflinfo.c
+++ b/src/utils/wflinfo.c
@@ -61,20 +61,20 @@ static const char *usage_message =
     "    Create an OpenGL or OpenGL ES context and print information about it.\n"
     "\n"
     "Required Parameters:\n"
-    "    --platform\n"
+    "    -p, --platform\n"
     "        One of: android, cgl, gbm, glx, wayland or x11_egl\n"
     "\n"
-    "    --api\n"
+    "    -a, --api\n"
     "        One of: gl, gles1, gles2 or gles3\n"
     "\n"
     "Options:\n"
-    "    --version\n"
+    "    -V, --version\n"
     "        For example --api=gl --version=3.2 would request OpenGL 3.2.\n"
     "\n"
     "    --profile\n"
     "        One of: core, compat or none\n"
     "\n"
-    "    --verbose\n"
+    "    -v, --verbose\n"
     "        Print more information.\n"
     "\n"
     "    --forward-compatible\n"
@@ -87,14 +87,16 @@ static const char *usage_message =
     "    wflinfo --platform=glx --api=gl\n"
     "    wflinfo --platform=x11_egl --api=gl --version=3.2 --profile=core\n"
     "    wflinfo --platform=wayland --api=gles3\n"
+    "    wflinfo --platform=gbm --api=gl --version=3.2 --verbose\n"
+    "    wflinfo -p gbm -a gl -V 3.2 -v\n"
     ;
 
 enum {
-    OPT_PLATFORM = 1,
-    OPT_API,
-    OPT_VERSION,
+    OPT_PLATFORM = 'p',
+    OPT_API = 'a',
+    OPT_VERSION = 'V',
     OPT_PROFILE,
-    OPT_VERBOSE,
+    OPT_VERBOSE = 'v',
     OPT_DEBUG_CONTEXT,
     OPT_FORWARD_COMPATIBLE,
 };
@@ -304,7 +306,7 @@ parse_args(int argc, char *argv[], struct options *opts)
     opts->context_version = -1;
 
     while (loop_get_opt) {
-        int opt = getopt_long(argc, argv, "", get_opts, NULL);
+        int opt = getopt_long(argc, argv, "a:p:vV:", get_opts, NULL);
         switch (opt) {
             case -1:
                 loop_get_opt = false;
-- 
1.8.5.3



More information about the waffle mailing list