import time, datetime
import socket

from dogshell.common import report_errors, report_warnings, CommandLineClient

class MetricClient(CommandLineClient):

    def setup_parser(self, subparsers):
        parser = subparsers.add_parser('metric', help='Post metrics.')
        verb_parsers = parser.add_subparsers(title='Verbs')

        post_parser = verb_parsers.add_parser('post', help='Post metrics')
        post_parser.add_argument('name', help='metric name')
        post_parser.add_argument('value', help='metric value (integer or decimal value)', type=float)
        post_parser.add_argument('--host', help='scopes your metric to a specific host', default=None)
        post_parser.add_argument('--device', help='scopes your metric to a specific device', default=None)
        post_parser.add_argument('--localhostname', help='same as --host=`hostname` (overrides --host)', action='store_true')
        parser.set_defaults(func=self._post)

    def _post(self, args):
        self.dog.timeout = args.timeout
        if args.localhostname:
            host = find_localhost()
        else:
            host = args.host
        res = self.dog.metric(args.name, args.value, host=host, device=args.device)
        report_warnings(res)
        report_errors(res)

@@ -761,32 +761,126 @@
 , default=None)%0A
+        post_parser.add_argument('--tags', help='comma-separated list of tags', default=None)%0A
         post_par
@@ -985,24 +985,24 @@
 tore_true')%0A
-
         pars
@@ -1212,16 +1212,148 @@
 gs.host%0A
+        if args.tags:%0A            tags = sorted(set(%5Bt.strip() for t in%0A                               args.tags.split(',') if t%5D))%0A
         
@@ -1407,16 +1407,28 @@
 st=host,
+%0A           
  device=
@@ -1438,16 +1438,27 @@
 s.device
+, tags=tags
 )%0A      

add tags argument to metric post