code: def parse_args(self):
          self._compile()
          self.args = None
          self._self_event('before_parse', 'parse', *sys.argv[1:], **{})
          cmds = [cmd for cmd in sys.argv[1:] if not cmd.startswith("-")]
          if (len(cmds) > 0 and not utils.check_help() and self.default_cmd
                  and cmds[0] not in self.commands):
              sys.argv.insert(1, self.default_cmd)
          self.args = self.parser.parse_args()
          if self.args:
              if self.add_output and self.args.output is not None:
                  self.encoding = self.args.encoding
                  if self.args.encoding.lower() == 'raw':
                      self._output = open(self.args.output, self.args.write_mode)
                  else:
                      import codecs
                      self._output = codecs.open(
                          self.args.output, self.args.write_mode,
                          encoding=self.args.encoding)
              if self._cfg_factory:
                  self.cfg_file = self.args.config
              self._is_parsed = True
          return self