Repository: locustio/locust
File: locust/argument_parser.py (Python)

Code before:
    )
    # set the exit code to post on errors
    other_group.add_argument(
        '--exit-code-on-error',
        type=int,
        default=1,
        help="Sets the process exit code to use when a test result contain any failure or error"
    )
    other_group.add_argument(
        '-s', '--stop-timeout',
        action='store',
        type=int,
        dest='stop_timeout',
        default=None,
        help="Number of seconds to wait for a simulated user to complete any executing task before exiting. Default is to terminate immediately. This parameter only needs to be specified for the master process when running Locust distributed."
    )
    
    locust_classes_group = parser.add_argument_group("Locust user classes")
    locust_classes_group.add_argument(
        'locust_classes',
        nargs='*',
        metavar='LocustClass',
        help="Optionally specify which Locust classes that should be used (available Locust classes can be listed with -l or --list)",
    )
    parser.add_argument(
        '-B', '--web-auth',
        type=str,
        dest='web_auth',
        default=None,
        help='Set the Basic Auth for the UI (fmt: username:password)'
    )

def get_parser(default_config_files=DEFAULT_CONFIG_FILES):
    # get a parser that is only able to parse the -f argument
    parser = get_empty_argument_parser(add_help=True, default_config_files=default_config_files)
    # add all the other supported arguments
    setup_parser_arguments(parser)
    # fire event to provide a hook for locustscripts and plugins to add command line arguments
    locust.events.init_command_line_parser.fire(parser=parser)
    return parser


def parse_options(args=None):
    parser = get_parser()
    # parse command line and return options
    options = parser.parse_args(args=args)
    return options


Review comment (security):
I don't think we need a short hand `-B` for this option. `--web-auth` should be enough.

Code after:
    # Version number (optparse gives you --version but we have to do it
    # ourselves to get -V too. sigh)
    other_group.add_argument(
        '--version', '-V',
        action='version',
        help="Show program's version number and exit",
        version='%(prog)s {}'.format(version),
    )
    # set the exit code to post on errors
    other_group.add_argument(
        '--exit-code-on-error',
        type=int,
        default=1,
        help="Sets the process exit code to use when a test result contain any failure or error"
    )
    other_group.add_argument(
        '-s', '--stop-timeout',
        action='store',
        type=int,
        dest='stop_timeout',
        default=None,
        help="Number of seconds to wait for a simulated user to complete any executing task before exiting. Default is to terminate immediately. This parameter only needs to be specified for the master process when running Locust distributed."
    )
    
    locust_classes_group = parser.add_argument_group("Locust user classes")
    locust_classes_group.add_argument(
        'locust_classes',
        nargs='*',
        metavar='LocustClass',
        help="Optionally specify which Locust classes that should be used (available Locust classes can be listed with -l or --list)",
    )

def get_parser(default_config_files=DEFAULT_CONFIG_FILES):
    # get a parser that is only able to parse the -f argument
    parser = get_empty_argument_parser(add_help=True, default_config_files=default_config_files)
    # add all the other supported arguments
    setup_parser_arguments(parser)
    # fire event to provide a hook for locustscripts and plugins to add command line arguments
    locust.events.init_command_line_parser.fire(parser=parser)
    return parser


def parse_options(args=None):
    parser = get_parser()
    # parse command line and return options
    options = parser.parse_args(args=args)
    return options