Python Twisted using argparse module
Question:
I’m building Python Twisted applications and would like to use the argparse module to parse command line options, instead of the Twisted usage.Options, which seems kind of old school.
I’d like to run the app with twistd, and am concerned about argparse interfering with twistd’s command line argument parsing. I am seeking pointers, suggestions or opinions on what I’m trying to do.
Answers:
Your twistd
plugins are required to parse command-line options by providing a class with a parseOptions
method that takes an argv-style list. Beyond that, what you do is up to you. If you supply a class with that method that calls into argparse
, great.
I’m building Python Twisted applications and would like to use the argparse module to parse command line options, instead of the Twisted usage.Options, which seems kind of old school.
I’d like to run the app with twistd, and am concerned about argparse interfering with twistd’s command line argument parsing. I am seeking pointers, suggestions or opinions on what I’m trying to do.
Your twistd
plugins are required to parse command-line options by providing a class with a parseOptions
method that takes an argv-style list. Beyond that, what you do is up to you. If you supply a class with that method that calls into argparse
, great.