code: def add_arguments(self, parser):
          '''Add generic command-line arguments to a top-level argparse parser.
  
          After running this, the results from ``argparse.parse_args()``
          can be passed to :meth:`main`.
  
          '''
          commands = set(name[3:] for name in dir(self) if name.startswith('do_'))
          parser.add_argument('action', help='action to run', nargs='?',
                              choices=list(commands))
          parser.add_argument('arguments', help='arguments specific to ACTION',
                              nargs=argparse.REMAINDERf add_arguments(self, parser):
          '''Add generic command-line arguments to a top-level argparse parser.
  
          After running this, the results from ``argparse.parse_args()``
          can be passed to :meth:`main`.
  
          '''
          commands = set(name[3:] for name in dir(self) if name.startswith('do_'))
          parser.add_argument('action', help='action to run', nargs='?',
                              choices=list(commands))
          parser.add_argument('arguments', help='arguments specific to ACTION',
                              nargs=argparse.REMAINDER)
docs: Add generic command-line arguments to a top-level argparse parser.
  
          After running this, the results from ``argparse.parse_args()``
          can be passed to :meth:`main`.