mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
plugins: add 'flag' type for plugin options
Updates the plugin docs to include more detailed info about how options work. Changelog-Added: Plugins: 'flag'-type option now available.
This commit is contained in:
committed by
Rusty Russell
parent
a08905c344
commit
42cce55b45
@@ -250,8 +250,8 @@ class Plugin(object):
|
||||
"Name {} is already used by another option".format(name)
|
||||
)
|
||||
|
||||
if opt_type not in ["string", "int", "bool"]:
|
||||
raise ValueError('{} not in supported type set (string, int, bool)')
|
||||
if opt_type not in ["string", "int", "bool", "flag"]:
|
||||
raise ValueError('{} not in supported type set (string, int, bool, flag)')
|
||||
|
||||
self.options[name] = {
|
||||
'name': name,
|
||||
@@ -261,6 +261,15 @@ class Plugin(object):
|
||||
'value': None,
|
||||
}
|
||||
|
||||
def add_flag_option(self, name, description):
|
||||
"""Add a flag option that we'd like to register with lightningd.
|
||||
|
||||
Needs to be called before `Plugin.run`, otherwise we might not
|
||||
end up getting it set.
|
||||
|
||||
"""
|
||||
self.add_option(name, None, description, opt_type="flag")
|
||||
|
||||
def get_option(self, name):
|
||||
if name not in self.options:
|
||||
raise ValueError("No option with name {} registered".format(name))
|
||||
|
||||
Reference in New Issue
Block a user