# Path: syncano_cli/base/command.py
# class BaseInstanceCommand(BaseCommand):
#     """Command for Instance based commands: fetch data from an instance."""
#     def set_instance(self, instance_name):
#         self._set_instance(instance_name)
# 
#     def _set_instance(self, instance_name):
#         self.instance = get_instance(self.config_path, instance_name)
# 
# Path: syncano_cli/base/options.py
# class TopSpacedOpt(OptionsBase):
#     OPTIONS = ['space_top']
# 
#     def __init__(self, space_top=True, **kwargs):
#         super(TopSpacedOpt, self).__init__(space_top=space_top, **kwargs)
# 
# Path: syncano_cli/config_commands/exceptions.py
# class VariableInConfigException(CLIBaseException):
#     default_message = u'`{}` already in config, use `syncano config modify` instead.'
# 
# class VariableNotFoundException(CLIBaseException):
#     default_message = u'Variable `{}` not found.'


from syncano_cli.base.command import BaseInstanceCommand
from syncano_cli.base.options import TopSpacedOpt
from syncano_cli.config_commands.exceptions import VariableInConfigException, VariableNotFoundException
# -*- coding: utf-8 -*-



class ConfigCommand(BaseInstanceCommand):

    def config_show(self):
        config = self.instance.get_config()
        self._show_config(config)

    def _show_config(self, config):
        self.formatter.write('Config for Instance {}'.format(self.instance.name), TopSpacedOpt())
        self.formatter.display_config(config)

    def add(self, name, value):
        config = self.instance.get_config()
        if name in config:

# Path: syncano_cli/base/command.py
# class BaseInstanceCommand(BaseCommand):
#     """Command for Instance based commands: fetch data from an instance."""
#     def set_instance(self, instance_name):
#         self._set_instance(instance_name)
# 
#     def _set_instance(self, instance_name):
#         self.instance = get_instance(self.config_path, instance_name)
# 
# Path: syncano_cli/base/options.py
# class TopSpacedOpt(OptionsBase):
#     OPTIONS = ['space_top']
# 
#     def __init__(self, space_top=True, **kwargs):
#         super(TopSpacedOpt, self).__init__(space_top=space_top, **kwargs)
# 
# Path: syncano_cli/config_commands/exceptions.py
# class VariableInConfigException(CLIBaseException):
#     default_message = u'`{}` already in config, use `syncano config modify` instead.'
# 
# class VariableNotFoundException(CLIBaseException):
#     default_message = u'Variable `{}` not found.'


# Path: syncano_cli/config_commands/command.py
from syncano_cli.base.command import BaseInstanceCommand
from syncano_cli.base.options import TopSpacedOpt
from syncano_cli.config_commands.exceptions import VariableInConfigException, VariableNotFoundException

# -*- coding: utf-8 -*-



class ConfigCommand(BaseInstanceCommand):

    def config_show(self):
        config = self.instance.get_config()
        self._show_config(config)

    def _show_config(self, config):
        self.formatter.write('Config for Instance {}'.format(self.instance.name), TopSpacedOpt())
        self.formatter.display_config(config)

    def add(self, name, value):
        config = self.instance.get_config()
        if name in config:

            raise VariableInConfigException(format_args=[name])