def parse_cmd(self, tree, inp_cmd = None):
<EOL>self.exe = None<EOL>self.arg = None<EOL>self.exe_options = {}<EOL>self.children = tree['<STR_LIT>']<EOL>self.key = tree['<STR_LIT>']<EOL>option_parsing = False<EOL>self._scoop_rest_arguments = False<EOL>if inp_cmd is not None:<EOL><INDENT>self.inp_cmd = inp_cmd<EOL><DEDENT>i = <NUM_LIT:0><EOL>while i < len(self.inp_cmd):<EOL><INDENT>p = self.inp_cmd[i]<EOL>self.key = {}<EOL>if self.children is not None:<EOL><INDENT>self.key_complete = False<EOL>match = False<EOL>for param, content in self.children.items():<EOL><INDENT>if param.find(p) == <NUM_LIT:0>:<EOL><INDENT>self.key[param] = content<EOL>match = True<EOL>if p == param and len(self.inp_cmd) > i+<NUM_LIT:1>:<EOL><INDENT>self.key_complete = True<EOL>self.key = { param: content }<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if not match:<EOL><INDENT>if self._scoop_rest_arguments:<EOL><INDENT>self.arg.append(p)<EOL><DEDENT>else:<EOL><INDENT>raise InvalidCommand("<STR_LIT>" + p)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise InvalidCommand('<STR_LIT>')<EOL><DEDENT>if len(p) != <NUM_LIT:0> and len(self.key) == <NUM_LIT:1>:<EOL><INDENT>key, val = list(self.key.items())[<NUM_LIT:0>]<EOL>i, option_parsing = self._examine_key(key, val, p, i, option_parsing)<EOL><DEDENT>i += <NUM_LIT:1><EOL><DEDENT>
Extract command and options from string.

            The tree argument should contain a specifically formatted dict
            which describes the available commands, options, arguments and
            callbacks to methods for completion of arguments.
            TODO: document dict format

            The inp_cmd argument should contain a list of strings containing
            the complete command to parse, such as sys.argv (without the first
            element which specified the command itself).