Commit d320e341 authored by Seblu's avatar Seblu
Browse files

Global command refactoring

parent 783cff41
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ import StringIO
import cccli
from cccli.exception import *
from cccli.printer import Printer, color
from cccli.command import Command, Alias
from cccli.commands import Commands, Alias
from cccli.handler import CliHandler

from sjrpc.client import SimpleRpcClient
@@ -54,10 +54,12 @@ class Cli(object):
            self.printer.debug("Loaded history: %s"%len(self.printer.history))
            # enable completion
            self.printer.completion.set_completer(self._command_completer)
            # set prompt
        # load commands
        self.commands = Commands(self)
        self.printer.debug("Loaded commands: %d"%len(self.commands))
        # load alias
        self.alias.load(self.settings.get("alias", ""))
        self.printer.debug("Alias: %s"%self.alias)
        self.printer.debug("Loaded aliases: %d"%len(self.alias))
        # connecting
        self._connect()
        # auth
@@ -139,13 +141,13 @@ class Cli(object):
                argv[0] = "help"
            # execute command
            self.printer.debug("argv: %s"%argv)
            Command(argv, self).call()
            self.commands(argv)
        except cmdBadArgument as e:
            if str(e):
                self.printer.error("Bad argument: %s."%str(e))
            else:
                self.printer.error("Bad argument.")
            usage = Command.usage(argv[0])
            usage = self.commands.usage(argv[0])
            if usage != "":
                self.printer.out("usage: %s."%usage)
        except cmdBadName:
@@ -170,5 +172,5 @@ class Cli(object):
        if len(texte) > 0 and texte[0] == "!":
            return ()
        if len(texte) > 0 and texte[0] == "?":
            return [ "?%s"%c for c in  Command.list() + self.alias.keys() if c.startswith(texte[1:]) ]
        return [ c for c in  Command.list() + self.alias.keys() if c.startswith(texte) ]
            return [ "?%s"%c for c in  list(self.commands) + self.alias.keys() if c.startswith(texte[1:]) ]
        return [ c for c in  list(self.commands) + self.alias.keys() if c.startswith(texte) ]

cccli/command.py

deleted100644 → 0
+0 −585

File deleted.

Preview size limit exceeded, changes collapsed.

+20 −0
Original line number Diff line number Diff line
#!/usr/bin/env python
#coding=utf8

'''
CloudControl CLI Commands Package
'''

# bunch of command
from cccli.command.shell import *
from cccli.command.alias import *
from cccli.command.connection import *
from cccli.command.account import *
from cccli.command.right import *
from cccli.command.tag import *
from cccli.command.host import *
from cccli.command.vm import *

# by command module
from cccli.command.list import Command_list
from cccli.command.expert import Command_expert
+98 −0

File added.

Preview size limit exceeded, changes collapsed.

cccli/command/alias.py

0 → 100644
+41 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading