File: questions

package info (click to toggle)
python-milc 1.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 788 kB
  • sloc: python: 1,868; sh: 55; makefile: 3
file content (29 lines) | stat: -rwxr-xr-x 847 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
"""Hello World implementation using MILC.

PYTHON_ARGCOMPLETE_OK
"""
from milc import cli
from milc.questions import yesno, choice, question


@cli.argument('-y', '--yes', action='store_true', arg_only=True, help='Answer yes to all questions.')
@cli.argument('-n', '--no', action='store_true', arg_only=True, help='Answer no to all questions.')
@cli.entrypoint('Ask some questions.')
def main(cli):
    if yesno('Will you continue?'):
        cli.log.info('User has chosen to continue.')
    else:
        cli.log.info('User has chosen to stop.')

    if choice('Will you stop?', ['yes', 'no']) == 'no':
        cli.log.info('User is not stopping.')
    else:
        cli.log.info('User is stopping.')

    answer = question('Why? ')
    cli.log.info('Interesting answer: %s', answer)


if __name__ == '__main__':
    cli()