class HazAuth: """ Main command line interface """ def __init__(self): """ Initialize the plugin manager """ self.__pluginmanager = PluginManager() def _print_usage(self, should_list_plugins=False): print("Usage: {0} <plugin> <command> [<options>]".format(sys.argv[0])) if should_list_plugins: print("The following plugins are available:\n") self.__pluginmanager.help_all() def main(self, args): """ Validates user input and delegates to the plugin manager """ if len(args) == 0: self._print_usage(should_list_plugins=True) return os.EX_USAGE elif len(args) == 1: self._print_usage() # Call the given plugin without command to print # the help of the plugin self.__pluginmanager.call(args[0], None, None) return os.EX_USAGE else: # Call the command in the given plugin with the # remaining arguments return self.__pluginmanager.call(args[0], args[1], args[2:])
class Collector: """ Main command line interface """ def __init__(self): """ Initialize the plugin manager """ self.__pluginmanager = PluginManager() def parse_input(self): """ Validates user input and delegates to the plugin manager """ if len(sys.argv) > 1: print "The following plugins are available:\n" self.__pluginmanager.help_all() else: # Call the command in the given plugin with the # remaining arguments return self.__pluginmanager.call()
class CLI: """ Main command line interface. """ def __init__(self): """ Initialize the plugin manager. """ self.__pluginmanager = PluginManager() def parse_input(self): """ Validates user input and delegates execution to the plugin manager. """ if len(sys.argv) < 2: print "Usage: kahuna <plugin> <command> [<options>]" print "The following plugins are available:\n" self.__pluginmanager.help_all() elif len(sys.argv) == 2: print "Usage: kahuna <plugin> <command> [<options>]" # Call the given pugin without command to print the help of the plugin return self.__pluginmanager.call(sys.argv[1], None, None) else: # Call the command in the given plugin with the remaining of the arguments return self.__pluginmanager.call(sys.argv[1], sys.argv[2], sys.argv[3:])
class CLI: """ Main command line interface """ def __init__(self): """ Initialize the plugin manager """ self.__pluginmanager = PluginManager() def parse_input(self): """ Validates user input and delegates to the plugin manager """ if len(sys.argv) < 2: print "Usage: kahuna <plugin> <command> [<options>]" print "The following plugins are available:\n" self.__pluginmanager.help_all() elif len(sys.argv) == 2: print "Usage: kahuna <plugin> <command> [<options>]" # Call the given plugin without command to print # the help of the plugin return self.__pluginmanager.call(sys.argv[1], None, None) else: # Call the command in the given plugin with the # remaining of the arguments return self.__pluginmanager.call(sys.argv[1], sys.argv[2], sys.argv[3:])