Commit fe7f351d authored by ∞'s avatar 💻

Add default option value support

parent 08bc843e
Pipeline #5785 passed with stages
in 1 minute and 36 seconds
......@@ -14,12 +14,13 @@ def command(**config):
class Option:
def __init__(self, name, help=None, color=None, alias=None,
immediate=False):
immediate=False, default=None):
self.name = name
self.help = help or 'Undocumented option'
self.color = color or ''
self.alias = alias
self.immediate = immediate
self.default = default
def option(name, **cfg):
......
......@@ -41,6 +41,10 @@ class Parser:
for arg in self.argv:
self.append(arg)
for name, option in self.command.options.items():
if name not in self.options:
self.options[name] = option.default
def get_option(self, name):
name = name.lstrip('-')
for option in self.command.options.values():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment