MCPcopy
hub / github.com/mitmproxy/mitmproxy / add_option

Method add_option

mitmproxy/addonmanager.py:70–99  ·  view source on GitHub ↗

Add an option to mitmproxy. Help should be a single paragraph with no linebreaks - it will be reflowed by tools. Information on the data type should be omitted - it will be generated and added by tools as needed.

(
        self,
        name: str,
        typespec: type,
        default: Any,
        help: str,
        choices: Sequence[str] | None = None,
    )

Source from the content-addressed store, hash-verified

68 self.master = master
69
70 def add_option(
71 self,
72 name: str,
73 typespec: type,
74 default: Any,
75 help: str,
76 choices: Sequence[str] | None = None,
77 ) -> None:
78 """
79 Add an option to mitmproxy.
80
81 Help should be a single paragraph with no linebreaks - it will be
82 reflowed by tools. Information on the data type should be omitted -
83 it will be generated and added by tools as needed.
84 """
85 assert not isinstance(choices, str)
86 if name in self.master.options:
87 existing = self.master.options._options[name]
88 same_signature = (
89 existing.name == name
90 and existing.typespec == typespec
91 and existing.default == default
92 and existing.help == help
93 and existing.choices == choices
94 )
95 if same_signature:
96 return
97 else:
98 logger.warning("Over-riding existing option %s" % name)
99 self.master.options.add_option(name, typespec, default, help, choices)
100
101 def add_command(self, path: str, func: Callable) -> None:
102 """Add a command to mitmproxy.

Callers 15

test_loaderFunction · 0.95
loadMethod · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
test_setFunction · 0.45
loadMethod · 0.45
loadMethod · 0.45
loadMethod · 0.45

Calls

no outgoing calls

Tested by 10

test_loaderFunction · 0.76
loadMethod · 0.36
__init__Method · 0.36
__init__Method · 0.36
__init__Method · 0.36
__init__Method · 0.36
__init__Method · 0.36
__init__Method · 0.36
test_setFunction · 0.36
loadMethod · 0.36