Add an optional csv flag to the listCriteria command

BZ: 101806

The listCriteria command output is very dificult to parse. The default output
format contains a lot of useless formating character:
 $ listCriteria
 BandRinging:
 ============
 Possible states (Exclusive): {NetworkGenerated, PhoneGenerated}
 Current state = <none>

Add a optional csv flag. With this flag, each criterion info fits in one line, with each
field separated by commas:
 $ listCriteria csv
 Criterion name: BandRinging, type kind: exclusive, current state: <none>, states: {NetworkGenerated, PhoneGenerated}

Change-Id: I7f2b0a86405846b03cab7f4a3023503b69c6e29b
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Reviewed-on: http://android.intel.com:8080/102724
Reviewed-by: cactus <cactus@intel.com>
Reviewed-by: Denneulin, Guillaume <guillaume.denneulin@intel.com>
Reviewed-by: Gonzalve, Sebastien <sebastien.gonzalve@intel.com>
Tested-by: Dixon, CharlesX <charlesx.dixon@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp
index 24fd464..3af4c39 100644
--- a/parameter/ParameterMgr.cpp
+++ b/parameter/ParameterMgr.cpp
@@ -123,7 +123,7 @@
     { "getAutoSync", &CParameterMgr::getAutoSyncCommmandProcess, 0, "", "Show Auto Sync state" },
     { "sync", &CParameterMgr::syncCommmandProcess, 0, "", "Synchronize current settings to hardware while in Tuning Mode and Auto Sync off" },
     /// Criteria
-    { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0, "", "List selection criteria" },
+    { "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0, "[csv]", "List selection criteria" },
     /// Domains
     { "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0, "", "List configurable domains" },
     { "dumpDomains", &CParameterMgr::dumpDomainsCommmandProcess, 0, "", "Show all domains and configurations, including applicability conditions" },
@@ -831,9 +831,21 @@
 {
     (void)remoteCommand;
 
-    list<string> lstrResult;
+    bool humanReadable = true;
 
-    getSelectionCriteria()->listSelectionCriteria(lstrResult, true, true);
+    // Look for optional arguments
+    if (remoteCommand.getArgumentCount() >= 1) {
+
+        // If csv is provided, format the criterion list in Commas Separated Value pairs
+        if (remoteCommand.getArgument(0) == "csv") {
+            humanReadable = false;
+        } else {
+            return CCommandHandler::EShowUsage;
+        }
+    }
+
+    list<string> lstrResult;
+    getSelectionCriteria()->listSelectionCriteria(lstrResult, true, humanReadable);
 
     // Concatenate the criterion list as the command result
     CUtility::concatenate(lstrResult, strResult);