-
Notifications
You must be signed in to change notification settings - Fork 194
#1221 Added version checker #1226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I don't know why that pypy3.5 test is failing, I'll have to figure that out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this issue. Let me know if you have any questions about the changes I requested.
SoftLayer/CLI/core.py
Outdated
import time | ||
import traceback | ||
import types | ||
import urllib3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use requests
, which contains its own json stuff, so you can remove the json import as well.
And add this constant:
PROG_NAME = "slcli (SoftLayer Command-line)"
SoftLayer/CLI/core.py
Outdated
return latest | ||
|
||
|
||
def get_version_message(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will actually call get_latest_version()
for EVERY command run. So lets do the following:
def get_version_message(ctx, param, value):
if not value or ctx.resilient_parsing:
return
current = SoftLayer.consts.VERSION
latest = get_latest_version()
click.secho("Current: {prog} {current}\nLatest: {prog} v{latest}".format(
prog=PROG_NAME, current=current, latest=latest))
ctx.exit()
SoftLayer/CLI/core.py
Outdated
required=False, | ||
help="Use demo data instead of actually making API calls") | ||
@click.version_option(prog_name="slcli (SoftLayer Command-line)") | ||
@click.version_option(prog_name="slcli (SoftLayer Command-line)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing this will allow us to only query for the latest version only when someone actually runs --version
.
@click.option('--version', is_flag=True, expose_value=False, is_eager=True, callback=get_version,
help="Show version information.")
No description provided.