Revision a7aacf12 kamaki/cli/argument/__init__.py

b/kamaki/cli/argument/__init__.py
98 98
class ConfigArgument(Argument):
99 99
    """Manage a kamaki configuration (file)"""
100 100

  
101
    _config_file = None
101
    def __init__(self, help, parsed_name=('-c', '--config')):
102
        super(ConfigArgument, self).__init__(1, help, parsed_name, None)
103
        self.file_path = None
102 104

  
103 105
    @property
104 106
    def value(self):
105
        """A Config object"""
106
        super(self.__class__, self).value
107
        return super(self.__class__, self).value
107
        return super(ConfigArgument, self).value
108 108

  
109 109
    @value.setter
110 110
    def value(self, config_file):
111 111
        if config_file:
112 112
            self._value = Config(config_file)
113
            self._config_file = config_file
114
        elif self._config_file:
115
            self._value = Config(self._config_file)
113
            self.file_path = config_file
114
        elif self.file_path:
115
            self._value = Config(self.file_path)
116 116
        else:
117 117
            self._value = Config()
118 118

  
......
120 120
        """Get a configuration setting from the Config object"""
121 121
        return self.value.get(group, term)
122 122

  
123
    def get_groups(self):
123
    @property
124
    def groups(self):
124 125
        suffix = '_cli'
125 126
        slen = len(suffix)
126 127
        return [term[:-slen] for term in self.value.keys('global') if (
127 128
            term.endswith(suffix))]
128 129

  
129
    def get_cli_specs(self):
130
    @property
131
    def cli_specs(self):
130 132
        suffix = '_cli'
131 133
        slen = len(suffix)
132 134
        return [(k[:-slen], v) for k, v in self.value.items('global') if (
......
139 141
        return self.value.get_cloud(cloud, option)
140 142

  
141 143

  
142
_config_arg = ConfigArgument(
143
    1, 'Path to configuration file', ('-c', '--config'))
144
_config_arg = ConfigArgument('Path to config file')
144 145

  
145 146

  
146 147
class CmdLineConfigArgument(Argument):

Also available in: Unified diff