2020-08-10 14:36:05 +00:00
|
|
|
from ..core import Parser
|
|
|
|
|
2020-08-10 14:28:42 +00:00
|
|
|
from ._utils import SubCommand, DockerProgram
|
2020-08-08 17:41:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
class LogsCommand(SubCommand):
|
2020-08-10 13:48:15 +00:00
|
|
|
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
|
|
|
)
|
2020-08-08 17:41:11 +00:00
|
|
|
|
2020-08-10 13:48:15 +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']
|
|
|
|
|
2020-08-10 14:28:42 +00:00
|
|
|
DockerProgram('docker-compose').run(
|
2020-08-10 14:36:05 +00:00
|
|
|
args,
|
2020-08-10 14:28:42 +00:00
|
|
|
cwd='hello-world.project',
|
|
|
|
env={'COMPOSE_PROJECT_NAME': 'hello-world'}
|
|
|
|
)
|