code: def format_help(self) -> str:
          
          formatter = self._get_formatter()
  
          # usage
          formatter.add_usage(self.usage, self._actions,
                              self._mutually_exclusive_groups)
  
          # description
          formatter.add_text(self.description)
  
          # Begin cmd2 customization (separate required and optional arguments)
  
          # positionals, optionals and user-defined groups
          for action_group in self._action_groups:
              if action_group.title == 'optional arguments':
                  # check if the arguments are required, group accordingly
                  req_args = []
                  opt_args = []
                  for action in action_group._group_actions:
                      if action.required:
                          req_args.append(action)
                      else:
                          opt_args.append(action)
  
                  # separately display required arguments
                  formatter.start_section('required arguments')
                  formatter.add_text(action_group.description)
                  formatter.add_arguments(req_args)
                  formatter.end_section()
  
                  # now display truly optional arguments
                  formatter.start_section(action_group.title)
                  formatter.add_text(action_group.description)
                  formatter.add_arguments(opt_args)
                  formatter.end_section()
              else:
                  formatter.start_section(action_group.title)
                  formatter.add_text(action_group.description)
                  formatter.add_arguments(action_group._group_actions)
                  formatter.end_section()
  
          # End cmd2 customization
  
          # epilog
          formatter.add_text(self.epilog)
  
          # determine help from format above
          return formatter.format_help()
docs: Copy of format_help() from argparse.ArgumentParser with tweaks to separately display required parameters