preliminary work for class based plugins #27

pull/74/head
Mallory Hancock 2019-09-12 10:14:56 -07:00
parent fdb16287ce
commit 4ae8753095
1 changed files with 30 additions and 0 deletions

View File

@ -1,3 +1,4 @@
from abc import ABC, abstractmethod
from enum import Enum
from functools import wraps
@ -23,6 +24,35 @@ class Output:
return msg
class Command(ABC):
def __init__(self, **kwargs):
self.cmd = kwargs.get('cmd')
self.help = kwargs.get('help', '')
self.ops = kwargs.get('ops', False)
self.ops_msg = kwargs.get('ops_msg', '')
self.enabled = True
self.add_command()
@abstractmethod
def run(self, msg):
pass
def add_command(self):
cmds[self.cmd] = {
'run': self.run,
'help': self.help,
'enabled': self.enabled,
}
if self.ops:
cmds[self.cmd].update({
'ops': self.ops,
'ops_msg': self.ops_msg,
})
def __str__(self):
return self.cmd
def action(msg):
return Output(OutputType.Action, msg)