Add basic CLI
This commit is contained in:
parent
523fb99d79
commit
3b654ad349
10 changed files with 266 additions and 1 deletions
29
plum/cli/command.py
Normal file
29
plum/cli/command.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
from docker import Client
|
||||
import logging
|
||||
import os
|
||||
import yaml
|
||||
|
||||
from ..service_collection import ServiceCollection
|
||||
from .docopt_command import DocoptCommand
|
||||
from .formatter import Formatter
|
||||
from .utils import cached_property, mkdir
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class Command(DocoptCommand):
|
||||
@cached_property
|
||||
def client(self):
|
||||
if os.environ.get('DOCKER_URL'):
|
||||
return Client(os.environ['DOCKER_URL'])
|
||||
else:
|
||||
return Client()
|
||||
|
||||
@cached_property
|
||||
def service_collection(self):
|
||||
config = yaml.load(open('plum.yml'))
|
||||
return ServiceCollection.from_config(self.client, config)
|
||||
|
||||
@cached_property
|
||||
def formatter(self):
|
||||
return Formatter()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue