Skip to content
Snippets Groups Projects
command.py 778 B
Newer Older
Seblu's avatar
Seblu committed
#!/usr/bin/env python
#coding=utf8

'''
CloudControl CLI command module
'''

from optparse import OptionParser

Seblu's avatar
Seblu committed
class Command(object):

    def __init__(self, cli, argv0):
Seblu's avatar
Seblu committed
        self.cli = cli
        self.printer = self.cli.printer
Seblu's avatar
Seblu committed
    def __call__(self, argv):
        raise NotImplementedError

    def usage(self):
        return "Usage: %s"%self.name

    def help(self):
        return self.__doc__


class OptionCommand(Command):

    def __init__(self, cli, argv0):
        Command.__init__(self, cli, argv0)
        self.option = OptionParser(prog=argv0)
Seblu's avatar
Seblu committed

Seblu's avatar
Seblu committed
    def __call__(self, argv):
        raise NotImplementedError

Seblu's avatar
Seblu committed
    def usage(self):
        return self.option.format_help().strip()
Seblu's avatar
Seblu committed

    def help(self):
        return self.__doc__