autotest: add `atest server list -N` option to list only hostnames

BUG=chromium:721591
TEST=atest server list -N

Change-Id: Ia3a3cbecc901b8dc58e59d41bbf5057bb5396b00
Reviewed-on: https://chromium-review.googlesource.com/520122
Commit-Ready: Aviv Keshet <akeshet@chromium.org>
Tested-by: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>
diff --git a/cli/server.py b/cli/server.py
index 62b707d..b318d73 100644
--- a/cli/server.py
+++ b/cli/server.py
@@ -139,6 +139,10 @@
                                help='Format output as JSON.',
                                action='store_true',
                                default=False)
+        self.parser.add_option('-N', '--hostnames-only',
+                               help='Only return hostnames.',
+                               action='store_true',
+                               default=False)
 
 
     def parse(self):
@@ -149,9 +153,9 @@
         self.table = options.table
         self.status = options.status
         self.summary = options.summary
-        if self.table and self.summary:
-            self.invalid_syntax('Option --table and --summary cannot be both '
-                                'specified.')
+        self.namesonly = options.hostnames_only
+        if sum([self.table, self.summary, self.json, self.namesonly]) > 1:
+            self.invalid_syntax('May only specify up to 1 output-format flag.')
         return (options, leftover)
 
 
@@ -183,6 +187,8 @@
                 formatter = server_manager_utils.format_servers_table
             elif self.summary:
                 formatter = server_manager_utils.format_servers_summary
+            elif self.namesonly:
+                formatter = server_manager_utils.format_servers_nameonly
             else:
                 formatter = server_manager_utils.format_servers
             print formatter(results)