<filename>toollib/tcli/commands/_docker.py<gh_stars>100-1000
"""
@author axiner
@version v1.0.0
@created 2022/5/11 21:44
@abstract
@description
@history
"""
import sys

from toollib.tcli import here

from toollib import utils
from toollib.decorator import sys_required
from toollib.tcli.base import BaseCmd
from toollib.tcli.option import Options


class Cmd(BaseCmd):

    def __init__(self):
        super().__init__()

    def add_options(self):
        options = Options(
            name='docker操作',
            desc='docker操作',
            optional={
                self.install: None,
                self.tofile: None,
            }
        )
        return options

    @sys_required('centos|\.el\d', errmsg='centos|el')
    def install(self):
        shb = here.joinpath('commands/plugins/docker_install.sh.x')
        cmd = f'chmod u+x {shb} && {shb}'
        p = utils.syscmd(cmd)
        out, err = p.communicate()
        if out:
            sys.stdout.write(u'{0}'.format(out.decode('utf-8')))
        if err:
            sys.stderr.write(u'{0}'.format(err.decode('utf-8')))

    @sys_required('centos|\.el\d', errmsg='centos|el')
    def tofile(self):
        sys.stdout.write('努力实现中...')

<filename>toollib/tcli/commands/_docker.py<gh_stars>100-1000
"""
@author axiner
@version v1.0.0
@created 2022/5/11 21:44
@abstract
@description
@history
"""
import sys

from toollib.tcli import here

from toollib import utils
from toollib.decorator import sys_required
from toollib.tcli.base import BaseCmd
from toollib.tcli.option import Options


class Cmd(BaseCmd):

    def __init__(self):
        super().__init__()

    def add_options(self):
        options = Options(
            name='docker操作',
            desc='docker操作',
            optional={
                self.install: None,
                self.tofile: None,
            }
        )
        return options

    @sys_required('centos|\.el\d', errmsg='centos|el')
    def install(self):
        shb = here.joinpath('commands/plugins/docker_install.sh.x')
        cmd = f'chmod u+x {shb} && {shb}'
        p = utils.syscmd(cmd)
        out, err = p.communicate()
        if out:
            sys.stdout.write(u'{0}'.format(out.decode('utf-8')))
        if err:
            sys.stderr.write(u'{0}'.format(err.decode('utf-8')))

    @sys_required('centos|\.el\d', errmsg='centos|el')
    def tofile(self):
        sys.stdout.write('努力实现中...')

@author axiner @version v1.0.0 @created 2022/5/11 21:44 @abstract @description @history