Skip to content

Commit

Permalink
feat(main): Add main:start event
Browse files Browse the repository at this point in the history
  • Loading branch information
Toilal committed Dec 17, 2020
1 parent 852bafc commit 8764d01
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ddb/__main__.py
Expand Up @@ -386,6 +386,8 @@ def on_config_reloaded():
handle_command_line(command)

bus.on(events.config.reloaded.name, on_config_reloaded) # pylint:disable=no-member

events.main.start(command=command)
handle_command_line(command)

events.main.terminate(command=command)
Expand Down
12 changes: 9 additions & 3 deletions ddb/event/events.py
Expand Up @@ -2,9 +2,9 @@

from ddb.binary import Binary as BinaryType
from . import event


# pylint:disable=redefined-outer-name
from ..command import Command


class File:
"""
Expand Down Expand Up @@ -231,8 +231,14 @@ class Main:
Main function related events.
"""

@event("main:start")
def start(self, command: Command):
"""
Main start
"""

@event("main:terminate")
def terminate(self, command: str):
def terminate(self, command: Command):
"""
Main terminate
"""
Expand Down
5 changes: 3 additions & 2 deletions ddb/feature/core/actions.py
Expand Up @@ -21,6 +21,7 @@
from ddb.utils.table_display import get_table_display
from .. import features
from ...action.action import EventBinding
from ...command import Command
from ...config.flatten import flatten
from ...context import context

Expand Down Expand Up @@ -320,13 +321,13 @@ def event_bindings(self):
return events.main.terminate

@staticmethod
def execute(command: str):
def execute(command: Command):
"""
Check for updates
:param command command name
:return:
"""
if command not in ['activate', 'deactivate', 'run', 'self-update']:
if command.name not in ['activate', 'deactivate', 'run', 'self-update']:
cache = caches.get('core.check_for_update.version')
last_check = cache.get('last_check', None)
today = date.today()
Expand Down

0 comments on commit 8764d01

Please sign in to comment.