Revision 3fe56be4

b/kamaki/cli/commands/config_cli.py
32 32
# or implied, of GRNET S.A.
33 33

  
34 34
from kamaki.cli import command
35
from kamaki.cli.argument import FlagArgument
35 36
from kamaki.cli.commands import _command_init
36 37
from kamaki.cli.command_tree import CommandTree
37 38

  
38 39
config_cmds = CommandTree('config', 'Configuration commands')
39 40
_commands = [config_cmds]
40 41

  
42
about_options = '\nAbout options:\
43
    \n  syntax: [group.]option\
44
    \n  example: store.account\
45
    \n  special case: <option> is equivalent to global.<option>\
46
    \n  configuration file syntax:\
47
    \n    [group]\
48
    \n    option=value\
49
    \n    (more options can be set per group)'
50

  
41 51

  
42 52
@command(config_cmds)
43 53
class config_list(_command_init):
44
    """List configuration options"""
54
    """List all configuration options
55
    FAQ:
56
    Q: I haven't set any options!
57
    A: Defaults are used (override with /config set )
58
    Q: There are more options than I have set
59
    A: Default options remain if not explicitly replaced or deleted
60
    """
45 61

  
46 62
    def main(self):
47 63
        for section in sorted(self.config.sections()):
......
52 68

  
53 69
@command(config_cmds)
54 70
class config_get(_command_init):
55
    """Show a configuration option"""
71
    """Show a configuration option
72
    """
73

  
74
    __doc__ += about_options
56 75

  
57 76
    def main(self, option):
58 77
        section, sep, key = option.rpartition('.')
......
66 85
class config_set(_command_init):
67 86
    """Set a configuration option"""
68 87

  
88
    __doc__ += about_options
89

  
69 90
    def main(self, option, value):
70 91
        section, sep, key = option.rpartition('.')
71 92
        section = section or 'global'
......
76 97

  
77 98
@command(config_cmds)
78 99
class config_delete(_command_init):
79
    """Delete a configuration option (and use the default value)"""
100
    """Delete a configuration option
101
    Default values are not removed by default. To alter this behavior in a
102
    session, use --default.
103
    """
104

  
105
    arguments = dict(
106
        default=FlagArgument(
107
            'Remove default value as well (persists until end of sesion)',
108
            '--default')
109
    )
80 110

  
81 111
    def main(self, option):
82 112
        section, sep, key = option.rpartition('.')
83 113
        section = section or 'global'
84
        self.config.remove_option(section, key)
114
        self.config.remove_option(section, key, self['default'])
85 115
        self.config.write()
86 116
        self.config.reload()
b/kamaki/cli/config.py
128 128
            self.add_section(section)
129 129
        RawConfigParser.set(self, section, option, value)
130 130

  
131
    def remove_option(self, section, option):
131
    def remove_option(self, section, option, also_remove_default=False):
132 132
        try:
133
            if also_remove_default:
134
                DEFAULTS[section].pop(option)
133 135
            RawConfigParser.remove_option(self, section, option)
134 136
        except NoSectionError:
135 137
            pass

Also available in: Unified diff