Skip to content

Commit

Permalink
add version and check-update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy Wang authored and Tommy Wang committed Dec 5, 2016
1 parent 7c9a817 commit 793ac29
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 8 deletions.
53 changes: 45 additions & 8 deletions aws_workflow/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
get_region,
make_pass_decorator,
parse_query,
set_version,
)
from .version import __version__


log = logging.getLogger()
Expand Down Expand Up @@ -106,14 +108,14 @@ def script_filter(query, wf, default_command):
@cli.command('set-profile')
@click.argument('profile')
@pass_wf
def set_profile(profile, wf):
def do_set_profile(profile, wf):
log.info('setting profile to %s' % profile)
wf.settings['profile'] = profile


@cli.command('clear-cache')
@pass_wf
def clear_cache(wf):
def do_clear_cache(wf):
log.info('cache cleared')
def _filter(n):
return not n.endswith('.pid')
Expand All @@ -122,19 +124,25 @@ def _filter(n):

@cli.command('open-help')
@pass_wf
def clear_cache(wf):
def do_open_help(wf):
wf.open_help()


@cli.command('update-workflow')
@pass_wf
def update_workflow(wf):
def do_update_workflow(wf):
if wf.start_update():
log.info('updating alfred')
else:
log.info('no update found')


@cli.command('check-update')
@pass_wf
def do_check_update(wf):
wf.check_update(force=True)


@cli.command('background')
@click.option('--data_name', envvar='WF_CACHE_DATA_NAME')
@click.argument('command')
Expand Down Expand Up @@ -188,7 +196,7 @@ def list_profiles(query, wf, complete):
def clear_cache(query, wf):
'''clears cache'''
item = wf.add_item(
title='clear cache',
title='clear-cache',
subtitle='clears cache',
valid=True,
arg='clear-cache',
Expand All @@ -201,17 +209,46 @@ def clear_cache(query, wf):
@wf_commands.command('help')
@click.argument('query', required=False)
@pass_wf
def help(query, wf):
def open_help(query, wf):
'''opens help in browser'''
item = wf.add_item(
title='open help',
title='help',
subtitle='opens help in browser',
valid=True,
arg='open-help',
autocomplete='help')
item.setvar('action', 'run-script')
wf.send_feedback()


@wf_commands.command('check-update')
@click.argument('query', required=False)
@pass_wf
def check_update(query, wf):
'''checks for updates'''
item = wf.add_item(
title='check-update',
subtitle='checks for updates',
valid=True,
arg='check-update',
autocomplete='check-update')
item.setvar('action', 'run-script')
wf.send_feedback()


@wf_commands.command('version')
@click.argument('query', required=False)
@pass_wf
@set_version
def get_version(query, wf):
'''%s'''
item = wf.add_item(
title='version',
subtitle=version,
valid=False)
wf.send_feedback()


@root.command('+')
@click.argument('query', required=False)
@pass_wf
Expand Down Expand Up @@ -326,7 +363,7 @@ def main():
wf = workflow.Workflow3(
update_settings={
'github_slug': 'twang817/aws-alfred-workflow',
'version': 'v3.1.2',
'version': __version__,
},
help_url='https://github.com/twang817/aws-alfred-workflow/blob/master/README.md',
)
Expand Down
7 changes: 7 additions & 0 deletions aws_workflow/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import boto3
import click

from .version import __version__


log = logging.getLogger()

Expand Down Expand Up @@ -96,3 +98,8 @@ def autocomplete_group(wf, query, group, complete):
valid=True,
autocomplete=complete + item)
wf.send_feedback()


def set_version(f):
f.__doc__ = f.__doc__ % __version__
return f
1 change: 1 addition & 0 deletions aws_workflow/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = 'v3.1.2'

0 comments on commit 793ac29

Please sign in to comment.