~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shelf.py

Make help work properly based on options.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
 
104
104
 
105
105
class HunkSelector:
106
 
    __usage = """Your options are:
107
 
    y - keep this change in your tree.
108
 
    n - shelve this change for the moment.
109
 
    i - invert the current selection.
110
 
    s - status, show what's selected to be shelved.
111
 
    q - quit the shelve command.\n"""
112
 
 
113
106
    class Option:
114
 
        def __init__(self, char, action, default=False):
 
107
        def __init__(self, char, action, help, default=False):
115
108
            self.char = char
116
109
            self.action = action
117
110
            self.default = default
 
111
            self.help = help
118
112
 
119
113
    standard_options = [
120
 
        Option('n', 'shelve', default=True),
121
 
        Option('y', 'keep'),
122
 
        Option('d', 'done'),
123
 
        Option('i', 'invert'),
124
 
        Option('s', 'status'),
125
 
        Option('q', 'quit')
 
114
        Option('n', 'shelve', 'shelve this change for the moment.',
 
115
            default=True),
 
116
        Option('y', 'keep', 'keep this change in your tree.'),
 
117
        Option('d', 'done', 'done, skip to the end.'),
 
118
        Option('i', 'invert', 'invert the current selection of all hunks.'),
 
119
        Option('s', 'status', 'show status of hunks.'),
 
120
        Option('q', 'quit', 'quit')
126
121
    ]
127
122
 
128
123
    end_options = [
129
 
        Option('y', 'continue', default=True),
130
 
        Option('r', 'restart'),
131
 
        Option('s', 'status'),
132
 
        Option('i', 'invert'),
133
 
        Option('q', 'quit')
 
124
        Option('y', 'continue', 'proceed to shelve selected changes.',
 
125
            default=True),
 
126
        Option('r', 'restart', 'restart the hunk selection loop.'),
 
127
        Option('s', 'status', 'show status of hunks.'),
 
128
        Option('i', 'invert', 'invert the current selection of all hunks.'),
 
129
        Option('q', 'quit', 'quit')
134
130
    ]
135
131
 
136
132
    def __init__(self, patches):
289
285
                if opt.char == response:
290
286
                    return opt.action
291
287
 
292
 
            print self.__usage
 
288
            for opt in options:
 
289
                print '  %s - %s' % (opt.char, opt.help)