milc/questions
Zach White ca854efbc6
Only ask questions if we are an interactive process (#30)
* Only ask questions if we are an interactive process

* add tests for the question script

* tweak color

* add a breaking changes entry

* typo

* make ci happy
2021-05-17 16:11:41 -07:00

29 lines
847 B
Python
Executable file

#!/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()