Revision 56d84a4e kamaki/cli/command_shell.py
b/kamaki/cli/command_shell.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
from cmd import Cmd |
35 | 35 |
from os import popen |
36 |
from sys import stdout |
|
36 |
from sys import stdout, stderr
|
|
37 | 37 |
|
38 | 38 |
from kamaki.cli import exec_cmd, print_error_message, print_subcommands_help |
39 | 39 |
from kamaki.cli.argument import ArgumentParseManager |
... | ... | |
167 | 167 |
self.__dict__ = oldcontext |
168 | 168 |
|
169 | 169 |
@staticmethod |
170 |
def _create_help_method(cmd_name, args, descr, syntax): |
|
170 |
def _create_help_method(cmd_name, args, required, descr, syntax):
|
|
171 | 171 |
tmp_args = dict(args) |
172 | 172 |
#tmp_args.pop('options', None) |
173 | 173 |
tmp_args.pop('cloud', None) |
... | ... | |
175 | 175 |
tmp_args.pop('verbose', None) |
176 | 176 |
tmp_args.pop('silent', None) |
177 | 177 |
tmp_args.pop('config', None) |
178 |
help_parser = ArgumentParseManager(cmd_name, tmp_args) |
|
178 |
help_parser = ArgumentParseManager(cmd_name, tmp_args, required)
|
|
179 | 179 |
help_parser.parser.description = descr |
180 | 180 |
help_parser.syntax = syntax |
181 |
return help_parser.parser.print_help |
|
181 |
#return help_parser.parser.print_help |
|
182 |
return help_parser.print_help |
|
182 | 183 |
|
183 | 184 |
def _register_command(self, cmd_path): |
184 | 185 |
cmd = self.cmd_tree.get_command(cmd_path) |
... | ... | |
200 | 201 |
if subcmd.is_command: # exec command |
201 | 202 |
try: |
202 | 203 |
cls = subcmd.cmd_class |
204 |
cmd_parser.required = getattr(cls, 'required', None) |
|
203 | 205 |
ldescr = getattr(cls, 'long_description', '') |
204 | 206 |
if subcmd.path == 'history_run': |
205 | 207 |
instance = cls( |
... | ... | |
214 | 216 |
cmd_parser.syntax = '%s %s' % ( |
215 | 217 |
subcmd.path.replace('_', ' '), cls.syntax) |
216 | 218 |
help_method = self._create_help_method( |
217 |
cmd.name, cmd_parser.arguments, |
|
219 |
cmd.name, cmd_parser.arguments, cmd_parser.required,
|
|
218 | 220 |
subcmd.help, cmd_parser.syntax) |
219 | 221 |
if '-h' in cmd_args or '--help' in cmd_args: |
220 | 222 |
help_method() |
Also available in: Unified diff