def cmd(name, options='<STR_LIT>'):
<EOL>if options:<EOL><INDENT>try:<EOL><INDENT>docopt.docopt('<STR_LIT>' % (name, options, ), [])<EOL><DEDENT>except SystemExit:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>def decorator(func):<EOL><INDENT>def command_wrapper(pymux, arguments):<EOL><INDENT>if name == '<STR_LIT>' and '<STR_LIT>' not in arguments:<EOL><INDENT>for i, p in enumerate(arguments):<EOL><INDENT>if not p.startswith('<STR_LIT:->'):<EOL><INDENT>arguments.insert(i + <NUM_LIT:1>, '<STR_LIT>')<EOL>break<EOL><DEDENT><DEDENT><DEDENT>try:<EOL><INDENT>if six.PY2:<EOL><INDENT>arguments = [a.encode('<STR_LIT:utf-8>') for a in arguments]<EOL><DEDENT>received_options = docopt.docopt(<EOL>'<STR_LIT>' % (name, options),<EOL>arguments,<EOL>help=False)  <EOL>for k, v in received_options.items():<EOL><INDENT>if isinstance(v, six.binary_type):<EOL><INDENT>received_options[k] = v.decode('<STR_LIT:utf-8>')<EOL><DEDENT><DEDENT><DEDENT>except SystemExit:<EOL><INDENT>raise CommandException('<STR_LIT>' % (name, options))<EOL><DEDENT>func(pymux, received_options)<EOL>pymux.invalidate()<EOL><DEDENT>COMMANDS_TO_HANDLERS[name] = command_wrapper<EOL>COMMANDS_TO_HELP[name] = options<EOL>flags = re.findall(r'<STR_LIT>', options)<EOL>COMMANDS_TO_OPTION_FLAGS[name] = flags<EOL>return func<EOL><DEDENT>return decorator<EOL>
Decorator for all commands.

Commands will receive (pymux, variables) as input.
Commands can raise CommandException.