lshal: register options for ListCommand.

ListCommand parseArgs() and usage() uses a list of RegisteredOption's
instead of hardcoding all options.

Test: lshal_test
Change-Id: I94418b22791fbff7a17756c4266252a76570fb84
diff --git a/cmds/lshal/ListCommand.h b/cmds/lshal/ListCommand.h
index 346af28..5bc834c 100644
--- a/cmds/lshal/ListCommand.h
+++ b/cmds/lshal/ListCommand.h
@@ -17,6 +17,7 @@
 #ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_LIST_COMMAND_H_
 #define FRAMEWORK_NATIVE_CMDS_LSHAL_LIST_COMMAND_H_
 
+#include <getopt.h>
 #include <stdint.h>
 
 #include <fstream>
@@ -53,6 +54,27 @@
     std::string getName() const override { return GetName(); }
 
     static std::string GetName();
+
+    struct RegisteredOption {
+        // short alternative, e.g. 'v'. If '\0', no short options is available.
+        char shortOption;
+        // long alternative, e.g. 'init-vintf'
+        std::string longOption;
+        // no_argument, required_argument or optional_argument
+        int hasArg;
+        // value written to 'flag' by getopt_long
+        int val;
+        // operation when the argument is present
+        std::function<Status(ListCommand* thiz, const char* arg)> op;
+        // help message
+        std::string help;
+
+        const std::string& getHelpMessageForArgument() const;
+    };
+    // A list of acceptable command line options
+    // key: value returned by getopt_long
+    using RegisteredOptions = std::vector<RegisteredOption>;
+
 protected:
     Status parseArgs(const Arg &arg);
     Status fetch();
@@ -85,6 +107,8 @@
     NullableOStream<std::ostream> err() const;
     NullableOStream<std::ostream> out() const;
 
+    void registerAllOptions();
+
     Table mServicesTable{};
     Table mPassthroughRefTable{};
     Table mImplementationsTable{};
@@ -105,6 +129,12 @@
     // If an entry exist and not empty, it contains the cached content of /proc/{pid}/cmdline.
     std::map<pid_t, std::string> mCmdlines;
 
+    RegisteredOptions mOptions;
+    // All selected columns
+    std::vector<TableColumnType> mSelectedColumns;
+    // If true, emit cmdlines instead of PIDs
+    bool mEnableCmdlines = false;
+
 private:
     DISALLOW_COPY_AND_ASSIGN(ListCommand);
 };