コード例 #1
0
    def __init__(self, *args, **kwargs):
        self.multilineCommands = ['orate']
        self.maxrepeats = 3
        self.redirector = '->'

        # Add stuff to settable and/or shortcuts before calling base class initializer
        self.settable['maxrepeats'] = 'Max number of `--repeat`s allowed'

        # Need to use this older form of invoking super class constructor to support Python 2.x and Python 3.x
        Cmd.__init__(self, *args, **kwargs)
        self.intro = 'This is an intro banner ...'

        # Configure how arguments are parsed for @options commands
        set_posix_shlex(False)
        set_strip_quotes(True)
        set_use_arg_list(False)
コード例 #2
0
import textwrap
import time
import traceback
import weakref

import cmd2
import crcelk
import hyperlink

from . import __version__
from . import color
from . import conversion
from . import errors
from . import plugin_manager

cmd2.set_posix_shlex(True)


# this class includes both cmd2 style p* and generic style print_* methods for
# compatibility with cmd2.Cmd and the ConnectionDriver interface
class Engine(cmd2.Cmd):
    IOHistory = collections.namedtuple('IOHistory', ('rx', 'tx'))
    allow_cli_args = False
    prompt = 'pro > '

    def __init__(self, connection, plugins=None, quiet=False, **kwargs):
        self.exclude_from_help = ['do_eof', 'do_eos', 'do_quit']
        self.connection = connection
        if plugins is None:
            plugins = plugin_manager.PluginManager()
        elif not isinstance(plugins, plugin_manager.PluginManager):