From 7e18632d3e78585d3205e109f7f1fba360a7cbe0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 8 May 2010 06:37:08 -0400 Subject: [PATCH] Use .type.upper() (vs. old .name.upper()) for Argument.metavar. This conveys more information to the user output FILE compared to the same word twice: output OUTPUT Also rearranged some options. --- hooke/plugin/__init__.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hooke/plugin/__init__.py b/hooke/plugin/__init__.py index c3b25b7..42a758c 100644 --- a/hooke/plugin/__init__.py +++ b/hooke/plugin/__init__.py @@ -45,7 +45,8 @@ def Plugin (object): Fulfills the same role for Hooke that a software package does for an operating system. """ - name = "base plugin" + def __init__(self, name): + self.name = name def dependencies(self): """Return a list of Plugins we require.""" @@ -117,15 +118,15 @@ class Command (object): ITEM: Success """ - def __init__(self, name, arguments=[], aliases=None, help=''): + def __init__(self, name, aliases=None, arguments=[], help=''): self.name = name + if aliases == None: + aliases = [] + self.aliases = aliases self.arguments = [ Argument(name='help', type='bool', default=False, count=1, callback=StoreValue(True), help='Print a help message.'), ] + arguments - if aliases == None: - aliases = [] - self.aliases = aliases self._help = help def run(self, inqueue=None, outqueue=None, **kwargs): @@ -196,22 +197,22 @@ class Argument (object): TODO: ranges for `count`? """ - def __init__(self, name, type='string', metavar=None, default=None, - optional=True, count=1, completion_callback=None, - callback=None, aliases=None, help=''): + def __init__(self, name, aliases=None, type='string', metavar=None, + default=None, optional=True, count=1, + completion_callback=None, callback=None, help=''): self.name = name + if aliases == None: + aliases = [] + self.aliases = aliases self.type = type if metavar == None: - metavar = name.upper() + metavar = type.upper() self.metavar = metavar self.default = default self.optional = optional self.count = count self.completion_callback = completion_callback self.callback = callback - if aliases == None: - aliases = [] - self.aliases = aliases self._help = help def __str__(self): -- 2.26.2