about summary refs log tree commit diff
path: root/cli/start.c
diff options
context:
space:
mode:
Diffstat (limited to 'cli/start.c')
-rw-r--r--cli/start.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/cli/start.c b/cli/start.c
index 28d3ce1..e3a3684 100644
--- a/cli/start.c
+++ b/cli/start.c
@@ -4,24 +4,39 @@ void
 usage_start(void)
 {
     printf(
-        "Start torrents.\n"
+        "Activate torrents.\n"
         "\n"
-        "Usage: start torrent\n"
+        "Usage: start torrent ...\n"
+        "\n"
+        "Arguments:\n"
+        "torrent ...\n"
+        "\tThe torrents to activate.\n"
         "\n"
         );
     exit(1);
 }
 
+static struct option start_opts [] = {
+    { "help", no_argument, NULL, 'H' },
+    {NULL, 0, NULL, 0}
+};
+
 void
 cmd_start(int argc, char **argv)
 {
+    int ch;
     struct ipc_torrent t;
 
-    if (argc < 2)
+    while ((ch = getopt_long(argc, argv, "", start_opts, NULL)) != -1)
+        usage_start();
+    argc -= optind;
+    argv += optind;
+
+    if (argc < 1)
         usage_start();
 
     btpd_connect();
-    for (int i = 1; i < argc; i++)
+    for (int i = 0; i < argc; i++)
         if (torrent_spec(argv[i], &t))
             handle_ipc_res(btpd_start(ipc, &t), "start", argv[i]);
 }