Add task metadata
Metadata is supported in the config file on a per-task basis. It is to be put in the 'meta' key's value json. Currently 'title' and 'description' keys are supported. See the example below. ``` [ { "meta" : { "title" : "This is the title", "description" : "This is a longer description, not shown with -Q" } } ] ```
This commit is contained in:
parent
564c1f13bf
commit
18e84711ee
3 changed files with 28 additions and 0 deletions
|
@ -22,7 +22,11 @@ class Dispatcher(object):
|
|||
def dispatch(self, tasks):
|
||||
success = True
|
||||
for task in tasks:
|
||||
|
||||
for action in task:
|
||||
if action == 'meta':
|
||||
self._handle_metadata(task['meta'])
|
||||
continue
|
||||
handled = False
|
||||
for plugin in self._plugins:
|
||||
if plugin.can_handle(action):
|
||||
|
@ -42,5 +46,12 @@ class Dispatcher(object):
|
|||
self._plugins = [plugin(self._base_directory)
|
||||
for plugin in Executor.__subclasses__()]
|
||||
|
||||
def _handle_metadata(self, metadata):
|
||||
if 'title' in metadata:
|
||||
self._log.warning(metadata['title'])
|
||||
|
||||
if 'description' in metadata:
|
||||
self._log.info(' ' + metadata['description'])
|
||||
|
||||
class DispatchError(Exception):
|
||||
pass
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from .executor import Executor
|
||||
from .linker import Linker
|
||||
from .commandrunner import CommandRunner
|
||||
from .meta import Meta
|
||||
|
|
16
dotbot/executor/meta.py
Normal file
16
dotbot/executor/meta.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
from . import Executor
|
||||
|
||||
class Meta(Executor):
|
||||
'''
|
||||
Dummy handler for metadata support
|
||||
'''
|
||||
|
||||
_directive = 'meta'
|
||||
|
||||
def can_handle(self, directive):
|
||||
return directive == self._directive
|
||||
|
||||
def handle(self, directive, data):
|
||||
if directive != self._directive:
|
||||
raise ValueError('Header cannot handle directive %s' % directive)
|
||||
return True
|
Loading…
Reference in a new issue