1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-22 21:03:00 +00:00
kiwi-scp/src/kiwi/subcommands/logs.py

29 lines
717 B
Python
Raw Normal View History

2020-08-10 14:36:05 +00:00
from ..core import Parser
from ._utils import SubCommand, DockerProgram
class LogsCommand(SubCommand):
def __init__(self):
super().__init__(
'logs',
2020-08-10 14:36:05 +00:00
description="Show logs of a project or service"
)
self.get_parser().add_argument(
'-f', '--follow',
action='store_true',
help="output appended data as log grows"
2020-08-10 09:24:39 +00:00
)
def run(self):
2020-08-10 14:36:05 +00:00
args = ['logs', '-t']
if Parser().get_args().follow:
args = [*args, '-f', '--tail=10']
DockerProgram('docker-compose').run(
2020-08-10 14:36:05 +00:00
args,
cwd='hello-world.project',
env={'COMPOSE_PROJECT_NAME': 'hello-world'}
)