Remove Run
This commit is contained in:
parent
e469455bc0
commit
409b625309
@ -15,13 +15,31 @@ from .service import Service
|
|||||||
|
|
||||||
|
|
||||||
class ConsoleScript(cli2.ConsoleScript):
|
class ConsoleScript(cli2.ConsoleScript):
|
||||||
|
class Parser(cli2.Parser):
|
||||||
|
def parse(self):
|
||||||
|
super().parse()
|
||||||
|
if str(self.command) == 'help':
|
||||||
|
return
|
||||||
|
|
||||||
|
self.forward_args = []
|
||||||
|
|
||||||
|
found_dash = False
|
||||||
|
for arg in self.argv:
|
||||||
|
if arg == '--':
|
||||||
|
found_dash = True
|
||||||
|
if not found_dash:
|
||||||
|
continue
|
||||||
|
self.forward_args.append(arg)
|
||||||
|
|
||||||
|
self.funckwargs['cmd'] = self.forward_args
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
import inspect
|
import inspect
|
||||||
from podctl.podfile import Podfile
|
from podctl.podfile import Podfile
|
||||||
self.podfile = Podfile.factory(os.getenv('PODFILE', 'pod.py'))
|
self.podfile = Podfile.factory(os.getenv('PODFILE', 'pod.py'))
|
||||||
for name, script in self.podfile.pod.scripts.items():
|
for name, script in self.podfile.pod.scripts.items():
|
||||||
cb = self.podfile.pod.script(name)
|
cb = self.podfile.pod.script(name)
|
||||||
cb.__doc__ = inspect.getdoc(script)
|
cb.__doc__ = inspect.getdoc(script) or script.doc
|
||||||
self[name] = cli2.Callable(name, cb)
|
self[name] = cli2.Callable(name, cb)
|
||||||
return super().__call__(*args, **kwargs)
|
return super().__call__(*args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,3 @@
|
|||||||
import asyncio
|
|
||||||
import os
|
|
||||||
import shlex
|
|
||||||
|
|
||||||
from .build import Build
|
|
||||||
from .run import Run
|
|
||||||
from .visitable import Visitable
|
from .visitable import Visitable
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import os
|
|||||||
|
|
||||||
from .build import Build
|
from .build import Build
|
||||||
from .container import Container
|
from .container import Container
|
||||||
from .run import Run
|
|
||||||
from .script import Script
|
from .script import Script
|
||||||
from .visitable import Visitable
|
from .visitable import Visitable
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ from .visitable import Visitable
|
|||||||
class Pod(Visitable):
|
class Pod(Visitable):
|
||||||
default_scripts = dict(
|
default_scripts = dict(
|
||||||
build=Build(),
|
build=Build(),
|
||||||
run=Run(),
|
run=Script('run', 'Run a container command'),
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
from .script import Script
|
|
||||||
|
|
||||||
|
|
||||||
class Run(Script):
|
|
||||||
"""Run a container"""
|
|
||||||
@ -4,8 +4,9 @@ from .proc import Proc
|
|||||||
|
|
||||||
|
|
||||||
class Script:
|
class Script:
|
||||||
def __init__(self, name=None):
|
def __init__(self, name=None, doc=None):
|
||||||
self.name = name or type(self).__name__.lower()
|
self.name = name or type(self).__name__.lower()
|
||||||
|
self.doc = doc or 'Custom script'
|
||||||
|
|
||||||
async def exec(self, *args, **kwargs):
|
async def exec(self, *args, **kwargs):
|
||||||
"""Execute a command on the host."""
|
"""Execute a command on the host."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user