import collections


class Command:

    def __init__(self, cmd, args=None):
        '''
        Single command and it's output representation

        >>> c = Command('/remote-eq/status/show', ['--onuID=23', '--port=pon.7'])
        >>> c.compile()
        '/remote-eq/status/show --onuID=23 --port=pon.7'

        :param args: Additional command arguments. In python2, if you need to
            preserve order of arguments use ordered dict or list of 2-tuples
        :type args: list or dict
        '''
        self.cmd = cmd
        self.args = args or {}

    def _get_arg_strs(self):
        if not isinstance(self.args, collections.Mapping):
            if len(self.args) and isinstance(self.args[0], str):
                return list(self.args)
        return [
            "--%s=%s" % (arg, value)
            for arg, value in (
                self.args.items()
                if isinstance(self.args, collections.Mapping) else
                self.args
            )
        ]

    def compile(self):
        return " ".join([self.cmd] + self._get_arg_strs())

@@ -1,8 +1,21 @@
+import shlex%0A
 import c
@@ -27,16 +27,492 @@
 tions%0A%0A%0A
+def arg2tuple(arg):%0A    '''%0A    Parse command line argument into name, value tuple%0A    '''%0A    name, value = arg.split('=', 1)%0A%0A    if name.startswith('--'):%0A        name = name%5B2:%5D%0A%0A    # try to normalize string that's quoted%0A    _value = shlex.split(value)%0A    # other length than 1 means that the value string was either not properly%0A    # quoted or is empty, in both cases we're not touching it%0A    if len(_value) == 1:%0A        value = _value%5B0%5D%0A%0A    return name, value%0A%0A%0A
 class Co
@@ -668,21 +668,16 @@
 q/status
-/show
 ', %5B'--o
@@ -757,13 +757,8 @@
 atus
-/show
  --o
@@ -780,16 +780,86 @@
 pon.7'%0A%0A
+        :param cmd: Full path to the command.%0A        :type cmd: str%0A%0A
         

Add function for parsing cli arguments