Exemple #1
0
import inquiry
import json

try:
    result = inquiry.prompt([{
        'type':
        'rawlist',
        'name':
        'theme',
        'message':
        'What do you want to do?',
        'choices': [
            'Order a pizza', 'Make a reservation',
            inquiry.Separator(), 'Ask opening hours',
            'Talk to the receptionist'
        ]
    }, {
        'type':
        'rawlist',
        'name':
        'size',
        'message':
        'What size do you need',
        'choices': ['Jumbo', 'Large', 'Standard', 'Medium', 'Small', 'Micro'],
        'filter':
        lambda val: val.lower(),
    }])
except KeyboardInterrupt:
    print 'Aborted.'
else:
    print json.dumps(result, indent=2)
Exemple #2
0
import inquiry
import json

try:
    result = inquiry.prompt([{
        'type':
        'checkbox',
        'message':
        'Select toppings',
        'name':
        'toppings',
        'choices': [
            inquiry.Separator(' = The Meats = '), {
                'name': 'Pepperoni'
            }, {
                'name': 'Ham'
            }, {
                'name': 'Ground Meat'
            }, {
                'name': 'Bacon'
            },
            inquiry.Separator(' = The Cheeses = '), {
                'name': 'Mozzarella',
                'checked': True
            }, {
                'name': 'Cheddar'
            }, {
                'name': 'Parmesan'
            },
            inquiry.Separator(' = The usual ='), {
                'name': 'Mushroom'
Exemple #3
0
import inquiry
import json

try:
    result = inquiry.prompt([
        {
            'type': 'list',
            'name': 'theme',
            'message': 'What do you want to do?',
            'choices': [
                'Order a pizza',
                'Make a reservation',
                inquiry.Separator(),
                'Ask for opening hours',
                {
                    'name': 'Contact support',
                    'disabled': 'Unavailable at this time'
                },
                'Talk to the receptionist'
            ]
        },
        {
            'type': 'list',
            'name': 'size',
            'message': 'What size do you need?',
            'choices': ['Jumbo', 'Large', 'Standard', 'Medium', 'Small', 'Micro'],
            'filter': lambda val: val.lower(),
        }
    ])
except KeyboardInterrupt:
    print 'Aborted.'