~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/option.py

- refactor handling of short option names

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
    OPTIONS = {}
113
113
    SHORT_OPTIONS = {}
114
114
 
115
 
    def __init__(self, name, help='', type=None, argname=None):
 
115
    def __init__(self, name, help='', type=None):
116
116
        """Make a new command option.
117
117
 
118
118
        name -- regular name of the command, used in the double-dash
123
123
 
124
124
        type -- function called to parse the option argument, or 
125
125
            None (default) if this option doesn't take an argument.
126
 
 
127
 
        argname -- name of option argument, if any
128
126
        """
129
127
        # TODO: perhaps a subclass that automatically does 
130
128
        # --option, --no-option for reversable booleans
131
129
        self.name = name
132
130
        self.help = help
133
131
        self.type = type
134
 
        if type is None:
135
 
            assert argname is None
136
 
        elif argname is None:
137
 
            argname = 'ARG'
138
 
        self.argname = argname
139
132
 
140
133
    def short_name(self):
141
134
        """Return the single character option for this command, if any.
150
143
    Option.OPTIONS[name] = Option(name, **kwargs)
151
144
 
152
145
_global_option('all')
153
 
_global_option('clobber')
154
146
_global_option('basis', type=str)
155
147
_global_option('diff-options', type=str)
156
 
_global_option('help',
157
 
               help='show help message')
 
148
_global_option('help')
158
149
_global_option('file', type=unicode)
159
150
_global_option('force')
160
151
_global_option('format', type=unicode)
161
152
_global_option('forward')
162
153
_global_option('message', type=unicode)
163
154
_global_option('no-recurse')
164
 
_global_option('profile',
165
 
               help='show performance profiling information')
 
155
_global_option('profile')
166
156
_global_option('revision', type=_parse_revision_str)
167
157
_global_option('short')
168
 
_global_option('show-ids', 
169
 
               help='show internal object ids')
170
 
_global_option('timezone', 
171
 
               type=str,
172
 
               help='display timezone as local, original, or utc')
173
 
_global_option('verbose',
174
 
               help='display more information')
 
158
_global_option('show-ids')
 
159
_global_option('timezone', type=str)
 
160
_global_option('verbose')
175
161
_global_option('version')
176
162
_global_option('email')
 
163
_global_option('unchanged')
177
164
_global_option('update')
178
165
_global_option('long')
179
166
_global_option('root', type=str)