Improve the cli.AskUser() function
authorIustin Pop <iustin@google.com>
Wed, 19 Sep 2007 14:24:52 +0000 (14:24 +0000)
committerIustin Pop <iustin@google.com>
Wed, 19 Sep 2007 14:24:52 +0000 (14:24 +0000)
commit479887787ca5ef7eb8894aefc72bf36d485f87fb
tree68911e3dac84c9795185948b3a37ebfd22e01f54
parentbdd55f717237ce80b54deb09aad39a143d1aaa41
Improve the cli.AskUser() function

This patch improves the AskUser function by allowing it to:
 - choose from multiple choices (instead of only y/n)
 - give help to the user
 - preserve line breaks and whitespace formatting in the message

With this patch, an instance removal looks like this:
root@xen-test1-4:~# gnt-instance remove tsetest1
This will remove the volumes of the instance tsetest1 (including
mirrors), thus removing all the data of the instance. Continue?
y/[n]/?: ?
 y - Perform the operation
 n - Do not perform the operation

This will remove the volumes of the instance tsetest1 (including
mirrors), thus removing all the data of the instance. Continue?
y/[n]/?: y

The patch also removed the _ask_user member of the opts argument, since
external code was using it (and thus it makes no sense for it to be a
private member); now gnt-* scripts are using the AskUser function
directly.

Reviewed-by: ultrotter
lib/cli.py
scripts/gnt-cluster
scripts/gnt-instance