Newer
Older
#!/usr/bin/env python
#coding=utf8
'''
CloudControl alias related command
'''
from cccli.exception import *
from cccli.command.command import OptionCommand
import re
def __init__(self, cli, argv0):
OptionCommand.__init__(self, cli, argv0)
self.set_usage("%prog [options] [name] [value]")
# args parse
self.parse_args(argv)
_value = None
if len(self.args) == 0:
elif len(self.args) == 2:
_alias = self.args[0]
_value = self.args[1]
if a in self.cli.aliases:
self.printer.out("%s \"%s\""%(a, re.sub("\"", "\\\"", self.cli.aliases[a])))
else:
self.printer.warn("No alias %s"%a)
# editing
else:
self.cli.aliases[_alias] = _value
try:
self.cli.aliases.save(self.cli.settings.get("alias", None))
except Exception as e:
raise cmdError(e)
def __init__(self, cli, argv0):
OptionCommand.__init__(self, cli, argv0)
self.set_usage("%prog [options] [name]")
# parse args
self.parse_args(argv)
if len(self.args) != 1:
raise cmdBadArgument("%s: No such alias"%self.args[0])
# deleting aliases