-1

I was able to add custom command line parameters to locust script like below - ''' @events.init_command_line_parser.add_listener def init_parser(parser): parser.add_argument( '--custom-argument', help="It's working" ) '''

But I am unable to use the custom argument anywhere else in the script.

1 Answers1

2

You can access command line options via the environment. You can create another function tagged with the init listener to access it and save it into some other variable you can use anywhere. This was adapted from the example:

custom = None
@events.init.add_listener
def _(environment, **kw):
    global custom
    custom = environment.parsed_options.custom_argument
Solowalker
  • 2,431
  • 8
  • 13