"logs" command with "-f" switch
This commit is contained in:
parent
717e1ec81e
commit
02c2945ecf
1 changed files with 14 additions and 2 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
from ..core import Parser
|
||||||
|
|
||||||
from ._utils import SubCommand, DockerProgram
|
from ._utils import SubCommand, DockerProgram
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,12 +7,22 @@ class LogsCommand(SubCommand):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(
|
super().__init__(
|
||||||
'logs',
|
'logs',
|
||||||
description="Show logs of a project"
|
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"
|
||||||
)
|
)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
args = ['logs', '-t']
|
||||||
|
if Parser().get_args().follow:
|
||||||
|
args = [*args, '-f', '--tail=10']
|
||||||
|
|
||||||
DockerProgram('docker-compose').run(
|
DockerProgram('docker-compose').run(
|
||||||
['logs', '-tf', '--tail=10'],
|
args,
|
||||||
cwd='hello-world.project',
|
cwd='hello-world.project',
|
||||||
env={'COMPOSE_PROJECT_NAME': 'hello-world'}
|
env={'COMPOSE_PROJECT_NAME': 'hello-world'}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue