Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp	(revision 33758)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp	(revision 33759)
@@ -61,5 +61,5 @@
     return "Unknown";
 }
-#endif
+#endif /* VBOX_WITH_HOSTNETIF_API */
 
 static const char*getDeviceTypeText(DeviceType_T enmType)
@@ -186,135 +186,57 @@
 }
 
-enum enOptionCodes
+/**
+ * The type of lists we can produce.
+ */
+enum enmListType
 {
-    LISTVMS = 1000,
-    LISTRUNNINGVMS,
-    LISTOSTYPES,
-    LISTHOSTDVDS,
-    LISTHOSTFLOPPIES,
-    LISTBRIDGEDIFS,
+    kListNotSpecified = 1000,
+    kListVMs,
+    kListRunningVMs,
+    kListOsTypes,
+    kListHostDvds,
+    kListHostFloppies,
+    kListBridgedInterfaces,
 #if defined(VBOX_WITH_NETFLT)
-    LISTHOSTONLYIFS,
+    kListHostOnlyInterfaces,
 #endif
-    LISTHOSTCPUIDS,
-    LISTHOSTINFO,
-    LISTHDDBACKENDS,
-    LISTHDDS,
-    LISTDVDS,
-    LISTFLOPPIES,
-    LISTUSBHOST,
-    LISTUSBFILTERS,
-    LISTSYSTEMPROPERTIES,
-    LISTDHCPSERVERS,
-    LISTVRDELIBRARIES
+    kListHostCpuIDs,
+    kListHostInfo,
+    kListHddBackends,
+    kListHdds,
+    kListDvds,
+    kListFloppies,
+    kListUsbHost,
+    kListUsbFilters,
+    kListSystemProperties,
+    kListDhcpServers,
+    kListVrdeLibraries
 };
 
-static const RTGETOPTDEF g_aListOptions[]
-    = {
-        { "--long",             'l',                    RTGETOPT_REQ_NOTHING },
-        { "vms",                LISTVMS,                RTGETOPT_REQ_NOTHING },
-        { "runningvms",         LISTRUNNINGVMS,         RTGETOPT_REQ_NOTHING },
-        { "ostypes",            LISTOSTYPES,            RTGETOPT_REQ_NOTHING },
-        { "hostdvds",           LISTHOSTDVDS,           RTGETOPT_REQ_NOTHING },
-        { "hostfloppies",       LISTHOSTFLOPPIES,       RTGETOPT_REQ_NOTHING },
-        { "hostifs",            LISTBRIDGEDIFS,         RTGETOPT_REQ_NOTHING }, /* backward compatibility */
-        { "bridgedifs",         LISTBRIDGEDIFS,         RTGETOPT_REQ_NOTHING },
-#if defined(VBOX_WITH_NETFLT)
-        { "hostonlyifs",        LISTHOSTONLYIFS,        RTGETOPT_REQ_NOTHING },
-#endif
-        { "hostinfo",           LISTHOSTINFO,           RTGETOPT_REQ_NOTHING },
-        { "hostcpuids",         LISTHOSTCPUIDS,         RTGETOPT_REQ_NOTHING },
-        { "hddbackends",        LISTHDDBACKENDS,        RTGETOPT_REQ_NOTHING },
-        { "hdds",               LISTHDDS,               RTGETOPT_REQ_NOTHING },
-        { "dvds",               LISTDVDS,               RTGETOPT_REQ_NOTHING },
-        { "floppies",           LISTFLOPPIES,           RTGETOPT_REQ_NOTHING },
-        { "usbhost",            LISTUSBHOST,            RTGETOPT_REQ_NOTHING },
-        { "usbfilters",         LISTUSBFILTERS,         RTGETOPT_REQ_NOTHING },
-        { "systemproperties",   LISTSYSTEMPROPERTIES,   RTGETOPT_REQ_NOTHING },
-        { "dhcpservers",        LISTDHCPSERVERS,        RTGETOPT_REQ_NOTHING },
-        { "vrdelibraries",      LISTVRDELIBRARIES,      RTGETOPT_REQ_NOTHING },
-      };
-
-int handleList(HandlerArg *a)
+
+/**
+ * Produces the specified listing.
+ *
+ * @returns S_OK or some COM error code that has been reported in full.
+ * @param   enmList             The list to produce.
+ * @param   fOptLong            Long (@c true) or short list format.
+ * @param   rptrVirtualBox      Reference to the IVirtualBox smart pointer.
+ */
+static HRESULT produceList(enum enmListType enmCommand, bool fOptLong, const ComPtr<IVirtualBox> &rptrVirtualBox)
 {
     HRESULT rc = S_OK;
-
-    bool fOptLong = false;
-
-    int command = 0;
-    int c;
-
-    RTGETOPTUNION ValueUnion;
-    RTGETOPTSTATE GetState;
-    RTGetOptInit(&GetState, a->argc, a->argv, g_aListOptions, RT_ELEMENTS(g_aListOptions),
-                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
-    while ((c = RTGetOpt(&GetState, &ValueUnion)))
+    switch (enmCommand)
     {
-        switch (c)
-        {
-            case 'l':  // --long
-                fOptLong = true;
-            break;
-
-            case LISTVMS:
-            case LISTRUNNINGVMS:
-            case LISTOSTYPES:
-            case LISTHOSTDVDS:
-            case LISTHOSTFLOPPIES:
-            case LISTBRIDGEDIFS:
-#if defined(VBOX_WITH_NETFLT)
-            case LISTHOSTONLYIFS:
-#endif
-            case LISTHOSTINFO:
-            case LISTHOSTCPUIDS:
-            case LISTHDDBACKENDS:
-            case LISTHDDS:
-            case LISTDVDS:
-            case LISTFLOPPIES:
-            case LISTUSBHOST:
-            case LISTUSBFILTERS:
-            case LISTSYSTEMPROPERTIES:
-            case LISTDHCPSERVERS:
-            case LISTVRDELIBRARIES:
-                if (command)
-                    return errorSyntax(USAGE_LIST, "Too many subcommands for \"list\" command.\n");
-
-                command = c;
-            break;
-
-            case VINF_GETOPT_NOT_OPTION:
-                return errorSyntax(USAGE_LIST, "Unknown subcommand \"%s\".", ValueUnion.psz);
-            break;
-
-            default:
-                if (c > 0)
-                {
-                    if (RT_C_IS_GRAPH(c))
-                        return errorSyntax(USAGE_LIST, "unhandled option: -%c", c);
-                    else
-                        return errorSyntax(USAGE_LIST, "unhandled option: %i", c);
-                }
-                else if (c == VERR_GETOPT_UNKNOWN_OPTION)
-                    return errorSyntax(USAGE_LIST, "unknown option: %s", ValueUnion.psz);
-                else if (ValueUnion.pDef)
-                    return errorSyntax(USAGE_LIST, "%s: %Rrs", ValueUnion.pDef->pszLong, c);
-                else
-                    return errorSyntax(USAGE_LIST, "%Rrs", c);
-        }
-    }
-
-    if (!command)
-        return errorSyntax(USAGE_LIST, "Missing subcommand for \"list\" command.\n");
-
-    /* which object? */
-    switch (command)
-    {
-        case LISTVMS:
+        case kListNotSpecified:
+            AssertFailed();
+            return E_FAIL;
+
+        case kListVMs:
         {
             /*
              * Get the list of all registered VMs
              */
-            com::SafeIfaceArray <IMachine> machines;
-            rc = a->virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
+            com::SafeIfaceArray<IMachine> machines;
+            rc = rptrVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
             if (SUCCEEDED(rc))
             {
@@ -325,19 +247,17 @@
                 {
                     if (machines[i])
-                        rc = showVMInfo(a->virtualBox,
-                                        machines[i],
-                                        (fOptLong) ? VMINFO_STANDARD : VMINFO_COMPACT);
-                }
-            }
-        }
-        break;
-
-        case LISTRUNNINGVMS:
+                        rc = showVMInfo(rptrVirtualBox, machines[i], fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
+                }
+            }
+            break;
+        }
+
+        case kListRunningVMs:
         {
             /*
              * Get the list of all _running_ VMs
              */
-            com::SafeIfaceArray <IMachine> machines;
-            rc = a->virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
+            com::SafeIfaceArray<IMachine> machines;
+            rc = rptrVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
             if (SUCCEEDED(rc))
             {
@@ -360,7 +280,6 @@
                                 case MachineState_Paused:
                                 case MachineState_TeleportingPausedVM:
-                                    rc = showVMInfo(a->virtualBox,
-                                                    machines[i],
-                                                    (fOptLong) ? VMINFO_STANDARD : VMINFO_COMPACT);
+                                    rc = showVMInfo(rptrVirtualBox, machines[i], fOptLong ? VMINFO_STANDARD : VMINFO_COMPACT);
+                                    break;
                             }
                         }
@@ -368,11 +287,11 @@
                 }
             }
-        }
-        break;
-
-        case LISTOSTYPES:
-        {
-            com::SafeIfaceArray <IGuestOSType> coll;
-            rc = a->virtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
+            break;
+        }
+
+        case kListOsTypes:
+        {
+            com::SafeIfaceArray<IGuestOSType> coll;
+            rc = rptrVirtualBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(coll));
             if (SUCCEEDED(rc))
             {
@@ -392,12 +311,12 @@
                 }
             }
-        }
-        break;
-
-        case LISTHOSTDVDS:
+            break;
+        }
+
+        case kListHostDvds:
         {
             ComPtr<IHost> host;
-            CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
-            com::SafeIfaceArray <IMedium> coll;
+            CHECK_ERROR(rptrVirtualBox, COMGETTER(Host)(host.asOutParam()));
+            com::SafeIfaceArray<IMedium> coll;
             CHECK_ERROR(host, COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(coll)));
             if (SUCCEEDED(rc))
@@ -414,12 +333,12 @@
                 }
             }
-        }
-        break;
-
-        case LISTHOSTFLOPPIES:
+            break;
+        }
+
+        case kListHostFloppies:
         {
             ComPtr<IHost> host;
-            CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
-            com::SafeIfaceArray <IMedium> coll;
+            CHECK_ERROR(rptrVirtualBox, COMGETTER(Host)(host.asOutParam()));
+            com::SafeIfaceArray<IMedium> coll;
             CHECK_ERROR(host, COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(coll)));
             if (SUCCEEDED(rc))
@@ -436,17 +355,18 @@
                 }
             }
-        }
-        break;
-
-        case LISTBRIDGEDIFS:
+            break;
+        }
+
+        /** @todo function. */
+        case kListBridgedInterfaces:
 #if defined(VBOX_WITH_NETFLT)
-        case LISTHOSTONLYIFS:
+        case kListHostOnlyInterfaces:
 #endif
         {
             ComPtr<IHost> host;
-            CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
-            com::SafeIfaceArray <IHostNetworkInterface> hostNetworkInterfaces;
+            CHECK_ERROR(rptrVirtualBox, COMGETTER(Host)(host.asOutParam()));
+            com::SafeIfaceArray<IHostNetworkInterface> hostNetworkInterfaces;
 #if defined(VBOX_WITH_NETFLT)
-            if (command == LISTBRIDGEDIFS)
+            if (enmCommand == kListBridgedInterfaces)
                 CHECK_ERROR(host, FindHostNetworkInterfacesOfType(HostNetworkInterfaceType_Bridged,
                                                                   ComSafeArrayAsOutParam(hostNetworkInterfaces)));
@@ -502,24 +422,22 @@
                 networkInterface->COMGETTER(NetworkName)(netName.asOutParam());
                 RTPrintf("VBoxNetworkName: %lS\n\n", netName.raw());
-
 #endif
             }
-        }
-        break;
-
-        case LISTHOSTINFO:
+            break;
+        }
+
+        /** @todo function. */
+        case kListHostInfo:
         {
             ComPtr<IHost> Host;
-            CHECK_ERROR(a->virtualBox, COMGETTER(Host)(Host.asOutParam()));
+            CHECK_ERROR(rptrVirtualBox, COMGETTER(Host)(Host.asOutParam()));
 
             RTPrintf("Host Information:\n\n");
 
-            LONG64 uTCTime = 0;
-            CHECK_ERROR(Host, COMGETTER(UTCTime)(&uTCTime));
-            RTTIMESPEC timeSpec;
-            RTTimeSpecSetMilli(&timeSpec, uTCTime);
-            char szTime[32] = {0};
-            RTTimeSpecToString(&timeSpec, szTime, sizeof(szTime));
-            RTPrintf("Host time: %s\n", szTime);
+            LONG64      u64UtcTime = 0;
+            CHECK_ERROR(Host, COMGETTER(UTCTime)(&u64UtcTime));
+            RTTIMESPEC  timeSpec;
+            char        szTime[32];
+            RTPrintf("Host time: %s\n", RTTimeSpecToString(RTTimeSpecSetMilli(&timeSpec, u64UtcTime), szTime, sizeof(szTime)));
 
             ULONG processorOnlineCount = 0;
@@ -557,11 +475,11 @@
             CHECK_ERROR(Host, COMGETTER(OSVersion)(oSVersion.asOutParam()));
             RTPrintf("Operating system version: %lS\n", oSVersion.raw());
-        }
-        break;
-
-        case LISTHOSTCPUIDS:
+            break;
+        }
+
+        case kListHostCpuIDs:
         {
             ComPtr<IHost> Host;
-            CHECK_ERROR(a->virtualBox, COMGETTER(Host)(Host.asOutParam()));
+            CHECK_ERROR(rptrVirtualBox, COMGETTER(Host)(Host.asOutParam()));
 
             RTPrintf("Host CPUIDs:\n\nLeaf no.  EAX      EBX      ECX      EDX\n");
@@ -586,15 +504,14 @@
                 }
             }
-        }
-        break;
-
-        case LISTHDDBACKENDS:
-        {
-            ComPtr<ISystemProperties> systemProperties;
-            CHECK_ERROR(a->virtualBox,
-                        COMGETTER(SystemProperties)(systemProperties.asOutParam()));
-            com::SafeIfaceArray <IMediumFormat> mediumFormats;
-            CHECK_ERROR(systemProperties,
-                        COMGETTER(MediumFormats)(ComSafeArrayAsOutParam(mediumFormats)));
+            break;
+        }
+
+        /** @todo function. */
+        case kListHddBackends:
+        {
+            ComPtr<ISystemProperties>           systemProperties;
+            CHECK_ERROR(rptrVirtualBox, COMGETTER(SystemProperties)(systemProperties.asOutParam()));
+            com::SafeIfaceArray<IMediumFormat>  mediumFormats;
+            CHECK_ERROR(systemProperties, COMGETTER(MediumFormats)(ComSafeArrayAsOutParam(mediumFormats)));
 
             RTPrintf("Supported hard disk backends:\n\n");
@@ -663,35 +580,36 @@
                 RTPrintf(")\n");
             }
-        }
-        break;
-
-        case LISTHDDS:
+            break;
+        }
+
+        case kListHdds:
         {
             com::SafeIfaceArray<IMedium> hdds;
-            CHECK_ERROR(a->virtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds)));
-            listMedia(a->virtualBox, hdds, "base");
-        }
-        break;
-
-        case LISTDVDS:
+            CHECK_ERROR(rptrVirtualBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hdds)));
+            listMedia(rptrVirtualBox, hdds, "base");
+            break;
+        }
+
+        case kListDvds:
         {
             com::SafeIfaceArray<IMedium> dvds;
-            CHECK_ERROR(a->virtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
-            listMedia(a->virtualBox, dvds, NULL);
-        }
-        break;
-
-        case LISTFLOPPIES:
+            CHECK_ERROR(rptrVirtualBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(dvds)));
+            listMedia(rptrVirtualBox, dvds, NULL);
+            break;
+        }
+
+        case kListFloppies:
         {
             com::SafeIfaceArray<IMedium> floppies;
-            CHECK_ERROR(a->virtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
-            listMedia(a->virtualBox, floppies, NULL);
-        }
-        break;
-
-        case LISTUSBHOST:
+            CHECK_ERROR(rptrVirtualBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppies)));
+            listMedia(rptrVirtualBox, floppies, NULL);
+            break;
+        }
+
+        /** @todo function. */
+        case kListUsbHost:
         {
             ComPtr<IHost> Host;
-            CHECK_ERROR_RET(a->virtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
+            CHECK_ERROR_RET(rptrVirtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
 
             SafeIfaceArray <IHostUSBDevice> CollPtr;
@@ -751,15 +669,21 @@
                     {
                         case USBDeviceState_NotSupported:
-                            pszState = "Not supported"; break;
+                            pszState = "Not supported";
+                            break;
                         case USBDeviceState_Unavailable:
-                            pszState = "Unavailable"; break;
+                            pszState = "Unavailable";
+                            break;
                         case USBDeviceState_Busy:
-                            pszState = "Busy"; break;
+                            pszState = "Busy";
+                            break;
                         case USBDeviceState_Available:
-                            pszState = "Available"; break;
+                            pszState = "Available";
+                            break;
                         case USBDeviceState_Held:
-                            pszState = "Held"; break;
+                            pszState = "Held";
+                            break;
                         case USBDeviceState_Captured:
-                            pszState = "Captured"; break;
+                            pszState = "Captured";
+                            break;
                         default:
                             ASSERT(false);
@@ -769,15 +693,16 @@
                 }
             }
-        }
-        break;
-
-        case LISTUSBFILTERS:
+            break;
+        }
+
+        /** @todo function. */
+        case kListUsbFilters:
         {
             RTPrintf("Global USB Device Filters:\n\n");
 
-            ComPtr <IHost> host;
-            CHECK_ERROR_RET(a->virtualBox, COMGETTER(Host)(host.asOutParam()), 1);
-
-            SafeIfaceArray <IHostUSBDeviceFilter> coll;
+            ComPtr<IHost> host;
+            CHECK_ERROR_RET(rptrVirtualBox, COMGETTER(Host)(host.asOutParam()), 1);
+
+            SafeIfaceArray<IHostUSBDeviceFilter> coll;
             CHECK_ERROR_RET(host, COMGETTER(USBDeviceFilters)(ComSafeArrayAsOutParam(coll)), 1);
 
@@ -833,11 +758,12 @@
                 }
             }
-        }
-        break;
-
-        case LISTSYSTEMPROPERTIES:
+            break;
+        }
+
+        /** @todo function. */
+        case kListSystemProperties:
         {
             ComPtr<ISystemProperties> systemProperties;
-            a->virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
+            rptrVirtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
 
             Bstr str;
@@ -907,11 +833,11 @@
             systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
             RTPrintf("Log history count:               %u\n", ulValue);
-
-        }
-        break;
-        case LISTDHCPSERVERS:
+            break;
+        }
+
+        case kListDhcpServers:
         {
             com::SafeIfaceArray<IDHCPServer> svrs;
-            CHECK_ERROR(a->virtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(svrs)));
+            CHECK_ERROR(rptrVirtualBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(svrs)));
             for (size_t i = 0; i < svrs.size(); ++i)
             {
@@ -932,15 +858,16 @@
                 svr->COMGETTER(UpperIP)(upperIp.asOutParam());
                 RTPrintf("upperIPAddress: %lS\n", upperIp.raw());
-                BOOL bEnabled;
-                svr->COMGETTER(Enabled)(&bEnabled);
-                RTPrintf("Enabled:        %s\n", bEnabled ? "Yes" : "No");
+                BOOL fEnabled;
+                svr->COMGETTER(Enabled)(&fEnabled);
+                RTPrintf("Enabled:        %s\n", fEnabled ? "Yes" : "No");
                 RTPrintf("\n");
             }
-        }
-        break;
-        case LISTVRDELIBRARIES:
+            break;
+        }
+
+        case kListVrdeLibraries:
         {
             SafeArray<BSTR> libs;
-            CHECK_ERROR(a->virtualBox, VRDEListLibraries(ComSafeArrayAsOutParam(libs)));
+            CHECK_ERROR(rptrVirtualBox, VRDEListLibraries(ComSafeArrayAsOutParam(libs)));
             for (size_t i = 0; i < libs.size(); ++i)
             {
@@ -948,9 +875,123 @@
                 RTPrintf("%lS\n", bstrName.raw());
             }
-        }
-        break;
-    } // end switch
-
-    return SUCCEEDED(rc) ? 0 : 1;
+            break;
+        }
+
+        /* No default here, want gcc warnings. */
+
+    } /* end switch */
+
+    return rc;
+}
+
+/**
+ * Handles the 'list' command.
+ *
+ * @returns Appropriate exit code.
+ * @param   a                   Handler argument.
+ */
+int handleList(HandlerArg *a)
+{
+    bool                fOptLong      = false;
+    bool                fOptMultiple  = false;
+    enum enmListType    enmOptCommand = kListNotSpecified;
+
+    static const RTGETOPTDEF s_aListOptions[] =
+    {
+        { "--long",             'l',                     RTGETOPT_REQ_NOTHING },
+        { "--multiple",         'm',                     RTGETOPT_REQ_NOTHING }, /* not offical yet */
+        { "vms",                kListVMs,                RTGETOPT_REQ_NOTHING },
+        { "runningvms",         kListRunningVMs,         RTGETOPT_REQ_NOTHING },
+        { "ostypes",            kListOsTypes,            RTGETOPT_REQ_NOTHING },
+        { "hostdvds",           kListHostDvds,           RTGETOPT_REQ_NOTHING },
+        { "hostfloppies",       kListHostFloppies,       RTGETOPT_REQ_NOTHING },
+        { "hostifs",            kListBridgedInterfaces,  RTGETOPT_REQ_NOTHING }, /* backward compatibility */
+        { "bridgedifs",         kListBridgedInterfaces,  RTGETOPT_REQ_NOTHING },
+#if defined(VBOX_WITH_NETFLT)
+        { "hostonlyifs",        kListHostOnlyInterfaces, RTGETOPT_REQ_NOTHING },
+#endif
+        { "hostinfo",           kListHostInfo,           RTGETOPT_REQ_NOTHING },
+        { "hostcpuids",         kListHostCpuIDs,         RTGETOPT_REQ_NOTHING },
+        { "hddbackends",        kListHddBackends,        RTGETOPT_REQ_NOTHING },
+        { "hdds",               kListHdds,               RTGETOPT_REQ_NOTHING },
+        { "dvds",               kListDvds,               RTGETOPT_REQ_NOTHING },
+        { "floppies",           kListFloppies,           RTGETOPT_REQ_NOTHING },
+        { "usbhost",            kListUsbHost,            RTGETOPT_REQ_NOTHING },
+        { "usbfilters",         kListUsbFilters,         RTGETOPT_REQ_NOTHING },
+        { "systemproperties",   kListSystemProperties,   RTGETOPT_REQ_NOTHING },
+        { "dhcpservers",        kListDhcpServers,        RTGETOPT_REQ_NOTHING },
+        { "vrdelibraries",      kListVrdeLibraries,      RTGETOPT_REQ_NOTHING },
+    };
+
+    int                 ch;
+    RTGETOPTUNION       ValueUnion;
+    RTGETOPTSTATE       GetState;
+    RTGetOptInit(&GetState, a->argc, a->argv, s_aListOptions, RT_ELEMENTS(s_aListOptions),
+                 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
+    while ((ch = RTGetOpt(&GetState, &ValueUnion)))
+    {
+        switch (ch)
+        {
+            case 'l':  /* --long */
+                fOptLong = true;
+                break;
+
+            case 'm':
+                fOptMultiple = true;
+                if (enmOptCommand == kListNotSpecified)
+                    break;
+                ch = enmOptCommand;
+                /* fall thru */
+
+            case kListVMs:
+            case kListRunningVMs:
+            case kListOsTypes:
+            case kListHostDvds:
+            case kListHostFloppies:
+            case kListBridgedInterfaces:
+#if defined(VBOX_WITH_NETFLT)
+            case kListHostOnlyInterfaces:
+#endif
+            case kListHostInfo:
+            case kListHostCpuIDs:
+            case kListHddBackends:
+            case kListHdds:
+            case kListDvds:
+            case kListFloppies:
+            case kListUsbHost:
+            case kListUsbFilters:
+            case kListSystemProperties:
+            case kListDhcpServers:
+            case kListVrdeLibraries:
+                enmOptCommand = (enum enmListType)ch;
+                if (fOptMultiple)
+                {
+                    HRESULT hrc = produceList((enum enmListType)ch, fOptLong, a->virtualBox);
+                    if (FAILED(hrc))
+                        return 1;
+                }
+                break;
+
+            case VINF_GETOPT_NOT_OPTION:
+                return errorSyntax(USAGE_LIST, "Unknown subcommand \"%s\".", ValueUnion.psz);
+
+            default:
+                return errorGetOpt(USAGE_LIST, ch, &ValueUnion);
+        }
+    }
+
+    /*
+     * If not in multiple list mode, we have to produce the list now.
+     */
+    if (enmOptCommand == kListNotSpecified)
+        return errorSyntax(USAGE_LIST, "Missing subcommand for \"list\" command.\n");
+    if (!fOptMultiple)
+    {
+        HRESULT hrc = produceList(enmOptCommand, fOptLong, a->virtualBox);
+        if (FAILED(hrc))
+            return 1;
+    }
+
+    return 0;
 }
 
