Use __str__ to print plugin arguments

This commit is contained in:
Gnarwhal 2024-09-04 17:53:01 +00:00
parent 86380766ac
commit 528115691a
Signed by: Gnarwhal
GPG key ID: 0989A73D8C421174
2 changed files with 5 additions and 5 deletions

View file

@ -150,7 +150,7 @@ def main():
if isinstance(plugin.activate, dict): if isinstance(plugin.activate, dict):
criteria = plugin.activate[plugin_type] criteria = plugin.activate[plugin_type]
for criterion in criteria: for criterion in criteria:
logger.error(f" {plugin.args[criterion].pretty()}") logger.error(f" {plugin.args[criterion]}")
error = True error = True
if error: if error:
sys.exit(1) sys.exit(1)

View file

@ -39,10 +39,7 @@ class Argument:
self.choices = choices self.choices = choices
self.help = help self.help = help
def is_valid(self): def __str__(self):
return (self.short != None and self.short != "") or (self.long != None and self.long != "")
def pretty(self):
if self.short and self.long: if self.short and self.long:
pretty = f"-{self.short}, --{self.long}" pretty = f"-{self.short}, --{self.long}"
elif self.long: elif self.long:
@ -51,6 +48,9 @@ class Argument:
pretty = f"-{self.short}" pretty = f"-{self.short}"
return pretty + f" {self.help}" return pretty + f" {self.help}"
def is_valid(self):
return (self.short != None and self.short != "") or (self.long != None and self.long != "")
def bind(self, plugin, argument): def bind(self, plugin, argument):
self.plugin = plugin self.plugin = plugin
self.metavar = argument self.metavar = argument