Revision c41eea6e lib/cli.py
b/lib/cli.py | ||
---|---|---|
314 | 314 |
|
315 | 315 |
|
316 | 316 |
def _ParseArgs(argv, commands, aliases): |
317 |
"""Parses the command line and return the function which must be |
|
318 |
executed together with its arguments |
|
317 |
"""Parser for the command line arguments. |
|
319 | 318 |
|
320 |
Arguments:
|
|
321 |
argv: the command line
|
|
319 |
This function parses the arguements and returns the function which
|
|
320 |
must be executed together with its (modified) arguments.
|
|
322 | 321 |
|
323 |
commands: dictionary with special contents, see the design doc for |
|
324 |
cmdline handling |
|
325 |
aliases: dictionary with command aliases {'alias': 'target, ...} |
|
322 |
@param argv: the command line |
|
323 |
@param commands: dictionary with special contents, see the design |
|
324 |
doc for cmdline handling |
|
325 |
@param aliases: dictionary with command aliases {'alias': 'target, ...} |
|
326 | 326 |
|
327 | 327 |
""" |
328 | 328 |
if len(argv) == 0: |
... | ... | |
439 | 439 |
def AskUser(text, choices=None): |
440 | 440 |
"""Ask the user a question. |
441 | 441 |
|
442 |
Args: |
|
443 |
text - the question to ask. |
|
442 |
@param text: the question to ask |
|
444 | 443 |
|
445 |
choices - list with elements tuples (input_char, return_value,
|
|
446 |
description); if not given, it will default to: [('y', True, |
|
447 |
'Perform the operation'), ('n', False, 'Do no do the operation')]; |
|
448 |
note that the '?' char is reserved for help |
|
444 |
@param choices: list with elements tuples (input_char, return_value,
|
|
445 |
description); if not given, it will default to: [('y', True,
|
|
446 |
'Perform the operation'), ('n', False, 'Do no do the operation')];
|
|
447 |
note that the '?' char is reserved for help
|
|
449 | 448 |
|
450 |
Returns: one of the return values from the choices list; if input is
|
|
451 |
not possible (i.e. not running with a tty, we return the last entry
|
|
452 |
from the list |
|
449 |
@return: one of the return values from the choices list; if input is
|
|
450 |
not possible (i.e. not running with a tty, we return the last
|
|
451 |
entry from the list
|
|
453 | 452 |
|
454 | 453 |
""" |
455 | 454 |
if choices is None: |
Also available in: Unified diff