I have a Python Cli application based on click framework ( https://click.palletsprojects.com/en/7.x/ ). It is released on Pypi.
How can I change my current Click CLI code so that user receive a message if there is a new release similar to "PIP UPGRADE WARNING" (after the CLI command is finished executing)
lets take a simple example. say the current version of my application is 10.1.2
import click
__version__ = '10.1.2'
@click.command()
@click.version_option(__version__, '-v', '--version', message='%(version)s')
@click.option('--name', default="John",
help='The person to greet.')
def hello(name):
"""Simple program that greets NAME for a total of COUNT times."""
click.echo('Hello %s!' % name)
if __name__ == '__main__':
hello()
current version is 10.1.2
python hello.py --version
10.1.2
If there is a new pypi release and new version is 11.1.1, user should get this output.
python hello.py
Hello John!
"You are using test version 10.1.2, however version 11.1.1 is available.
You should consider upgrading via the 'pip install --upgrade test' command."
Also, User should also have an ability to disable this feature if they want.