diff --git a/mitterlib/ui/cmd.py b/mitterlib/ui/cmd.py index 336ee25..2de141e 100644 --- a/mitterlib/ui/cmd.py +++ b/mitterlib/ui/cmd.py @@ -28,18 +28,14 @@ from mitterlib.network import NetworksNoNetworkSetupError, NetworksError from mitterlib.network.networkbase import NetworkError, \ NetworkPermissionDeniedError -namespace = 'cmd' # TODO: rename this var to NAMESPACE (check other files too) _log = logging.getLogger('ui.cmd') -def options(options): - # no options for this interface - return - - class Interface(cmd.Cmd): """The command line interface for Mitter.""" + NAMESPACE = 'cmd' + # ----------------------------------------------------------------------- # Methods required by cmd.Cmd (our commands) # ----------------------------------------------------------------------- @@ -324,3 +320,8 @@ class Interface(cmd.Cmd): warnings.simplefilter('error') # Warnings are exceptions self.cmdloop() return + + @classmethod + def options(self, options): + # no options for this interface + return diff --git a/mitterlib/ui/mh.py b/mitterlib/ui/mh.py index addae91..0d741c7 100644 --- a/mitterlib/ui/mh.py +++ b/mitterlib/ui/mh.py @@ -28,18 +28,14 @@ from mitterlib.network import NetworksNoNetworkSetupError, NetworksError from mitterlib.network.networkbase import NetworkError, \ NetworkPermissionDeniedError -namespace = 'cmd' # TODO: rename this var to NAMESPACE (check other files too) _log = logging.getLogger('ui.cmd') -def options(options): - # no options for this interface - return - - class Interface(cmd.Cmd): """A MH-like interface to Mitter.""" + NAMESPACE = 'mh' + # ----------------------------------------------------------------------- # Commands # ----------------------------------------------------------------------- @@ -161,3 +157,8 @@ class Interface(cmd.Cmd): warnings.simplefilter('error') # Warnings are exceptions self.cmdloop() return + + @classmethod + def options(self, options): + # no options for this interface + return diff --git a/mitterlib/ui/tty.py b/mitterlib/ui/tty.py index ca6f01f..838e86b 100644 --- a/mitterlib/ui/tty.py +++ b/mitterlib/ui/tty.py @@ -17,8 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -NAMESPACE = 'tty' - import mitterlib.ui.console_utils as console_utils import logging from mitterlib.network.networkbase import NetworkError @@ -27,41 +25,11 @@ from mitterlib.network import NetworksNoNetworkSetupError, NetworksError _log = logging.getLogger('ui.tty') -def options(options): - """Add command line options for this interface.""" - options.add_group(NAMESPACE, 'TTY interface') # This surely needs a - # better description - options.add_option('--messages', - group=NAMESPACE, - option='messages', - help='Display the latest messages.', - default=False, - action='store_true', - is_config_option=False, - conflict_group='interface') - options.add_option('--update', - group=NAMESPACE, - option='update', - default=None, - help='Update your status', - metavar='STATUS', - type='str', - is_config_option=False, - conflict_group='interface') - options.add_option('--replies', - group=NAMESPACE, - option='replies', - help='Get a list of replies instead of the friends timeline', - default=False, - action='store_true', - is_config_option=False, - conflict_group='interface') - return - - class Interface(object): """The console/tty interface for Mitter.""" + NAMESPACE = 'tty' + # ----------------------------------------------------------------------- # Private functions # ----------------------------------------------------------------------- @@ -117,14 +85,45 @@ class Interface(object): def __call__(self): """The callable function, used by mitter to start the interface.""" - status_message = self._options[NAMESPACE]['update'] + status_message = self._options[self.NAMESPACE]['update'] if status_message: self._update(status_message) return - if self._options[NAMESPACE]['replies']: + if self._options[self.NAMESPACE]['replies']: self._replies() return self._messages() return + + @classmethod + def options(self, options): + """Add command line options for this interface.""" + options.add_group(self.NAMESPACE, 'TTY interface') + options.add_option('--messages', + group=self.NAMESPACE, + option='messages', + help='Display the latest messages.', + default=False, + action='store_true', + is_config_option=False, + conflict_group='interface') + options.add_option('--update', + group=self.NAMESPACE, + option='update', + default=None, + help='Update your status', + metavar='STATUS', + type='str', + is_config_option=False, + conflict_group='interface') + options.add_option('--replies', + group=self.NAMESPACE, + option='replies', + help='Get a list of replies instead of the friends timeline', + default=False, + action='store_true', + is_config_option=False, + conflict_group='interface') + return