Revision 77e7bef7

b/kamaki/cli/command_shell.py
70 70

  
71 71
    undoc_header = 'interactive shell commands:'
72 72

  
73
    def postcmd(self, post, line):
74
        if self._context_stack:
75
            self._roll_command()
76
            self.set_prompt(self._prompt_stack.pop()[1:-2])
77
            self._restore(self._context_stack.pop())
78

  
79
        return Cmd.postcmd(self, post, line)
80

  
73 81
    def precmd(self, line):
74 82
        if line.startswith('/'):
75 83
            cur_cmd_path = self.prompt.replace(' ', '_')[1:-2]
76 84
            if cur_cmd_path != self.cmd_tree.name:
77 85
                cur_cmd = self.cmd_tree.get_command(cur_cmd_path)
78

  
79 86
                self._context_stack.append(self._backup())
80 87
                self._prompt_stack.append(self.prompt)
81 88
                new_context = self
82
                new_context._roll_command(cur_cmd_path)
89
                new_context._roll_command(cur_cmd.parent_path)
83 90
                new_context.set_prompt(self.cmd_tree.name)
84 91
                for grp_cmd in self.cmd_tree.get_subcommands():
85 92
                    self._register_command(grp_cmd.path)
......
118 125
        except KeyError:
119 126
            pass
120 127

  
121
    def _roll_command(self, cmd_path):
128
    def _roll_command(self, cmd_path=None):
122 129
        for subname in self.cmd_tree.get_subnames(cmd_path):
123 130
            self._unregister_method('do_%s' % subname)
124 131
            self._unregister_method('complete_%s' % subname)

Also available in: Unified diff