Index: uspace/app/tmon/Makefile
===================================================================
--- uspace/app/tmon/Makefile	(revision 64d138bec5d6824306e69dd9350f6058fb4a56a0)
+++ uspace/app/tmon/Makefile	(revision 73b0773c31969fd83f88107b0deb13625c49217b)
@@ -33,5 +33,6 @@
 
 SOURCES = \
-	main.c
+	main.c\
+	list.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/app/tmon/commands.h
===================================================================
--- uspace/app/tmon/commands.h	(revision 73b0773c31969fd83f88107b0deb13625c49217b)
+++ uspace/app/tmon/commands.h	(revision 73b0773c31969fd83f88107b0deb13625c49217b)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2017 Petr Manek
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup tmon
+ * @{
+ */
+/**
+ * @file USB diagnostic device commands.
+ */
+
+#ifndef TMON_COMMANDS_H_
+#define TMON_COMMANDS_H_
+
+int tmon_list(int, char **);
+
+#endif /* TMON_COMMANDS_H_ */
+
+/** @}
+ */
Index: uspace/app/tmon/list.c
===================================================================
--- uspace/app/tmon/list.c	(revision 73b0773c31969fd83f88107b0deb13625c49217b)
+++ uspace/app/tmon/list.c	(revision 73b0773c31969fd83f88107b0deb13625c49217b)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2017 Petr Manek
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup tmon
+ * @{
+ */
+/**
+ * @file
+ * USB transfer debugging.
+ */
+
+#include <stdio.h>
+#include <devman.h>
+#include <loc.h>
+#include <usb/diag/diag.h>
+#include <usb/diag/iface.h>
+#include <errno.h>
+#include "commands.h"
+
+#define NAME "tmon"
+
+static void print_list_item(service_id_t svc)
+{
+	int rc;
+	devman_handle_t diag_handle = 0;
+
+	if ((rc = devman_fun_sid_to_handle(svc, &diag_handle))) {
+		printf(NAME ": Error resolving handle of device with SID %ld, skipping.\n", svc);
+		return;
+	}
+
+	// FIXME: print something
+}
+
+int tmon_list(int argc, char *argv[])
+{
+	category_id_t diag_cat;
+	service_id_t *svcs;
+	size_t count;
+	int rc;
+
+	if ((rc = loc_category_get_id(USB_DIAG_CATEGORY, &diag_cat, 0))) {
+		printf(NAME ": Error resolving category '%s'", USB_DIAG_CATEGORY);
+		return 1;
+	}
+
+	if ((rc = loc_category_get_svcs(diag_cat, &svcs, &count))) {
+		printf(NAME ": Error getting list of host controllers.\n");
+		return 1;
+	}
+
+	for (unsigned i = 0; i < count; ++i) {
+		print_list_item(svcs[i]);
+	}
+
+	free(svcs);
+	return 0;
+}
+
+/** @}
+ */
Index: uspace/app/tmon/main.c
===================================================================
--- uspace/app/tmon/main.c	(revision 64d138bec5d6824306e69dd9350f6058fb4a56a0)
+++ uspace/app/tmon/main.c	(revision 73b0773c31969fd83f88107b0deb13625c49217b)
@@ -36,9 +36,5 @@
 
 #include <stdio.h>
-#include <loc.h>
-#include <usb/diag/diag.h>
-#include <usb/diag/iface.h>
-#include <devman.h>
-#include <errno.h>
+#include "commands.h"
 
 #define NAME "tmon"
@@ -49,48 +45,36 @@
 }
 
-static void print_list_item(service_id_t svc)
-{
-	int rc;
-	devman_handle_t diag_handle = 0;
+typedef struct {
+	const char *name;
+	int (*action)(int, char **);
+} usb_diag_cmd_t;
 
-	if ((rc = devman_fun_sid_to_handle(svc, &diag_handle))) {
-		printf(NAME ": Error resolving handle of device with SID %ld, skipping.\n", svc);
-		return;
+static usb_diag_cmd_t commands[] = {
+	{
+		.name = "list",
+		.action = tmon_list,
+	},
+	{
+		.name = NULL
 	}
-}
-
-static int print_list()
-{
-	category_id_t diag_cat;
-	service_id_t *svcs;
-	size_t count;
-	int rc;
-
-	if ((rc = loc_category_get_id(USB_DIAG_CATEGORY, &diag_cat, 0))) {
-		printf(NAME ": Error resolving category '%s'", USB_DIAG_CATEGORY);
-		return 1;
-	}
-
-	if ((rc = loc_category_get_svcs(diag_cat, &svcs, &count))) {
-		printf(NAME ": Error getting list of host controllers.\n");
-		return 1;
-	}
-
-	for (unsigned i = 0; i < count; ++i) {
-		print_list_item(svcs[i]);
-	}
-
-	free(svcs);
-	return 0;
-}
+};
 
 int main(int argc, char *argv[])
 {
-	if (argc <= 1) {
+	// Find a command to execute.
+	usb_diag_cmd_t *cmd = NULL;
+	for (int i = 0; argc > 1 && commands[i].name; ++i) {
+		if (str_cmp(argv[1], commands[i].name) == 0) {
+			cmd = commands + i;
+			break;
+		}
+	}
+
+	if (!cmd) {
 		print_usage(argv[0]);
 		return -1;
 	}
 
-	return print_list();
+	return cmd->action(argc - 2, argv + 2);
 }
 
