Beispiel #1
0
    def test_parser(self):

        parser = StatementParser()

        line = """
        SELECT *
        FROM elb_logs
        """
        statement = parser.parse(line)
        self.assertEqual(statement.command, 'SELECT')
        self.assertEqual(statement.command_and_args, 'SELECT * FROM elb_logs')

        line = """
        select *
        from elb_logs
        """
        statement = parser.parse(line)
        self.assertEqual(statement.command, 'select')
        self.assertEqual(statement.command_and_args, 'select * from elb_logs')
Beispiel #2
0
def parser():
    parser = StatementParser(allow_redirection=True,
                             terminators=[';', '&'],
                             multiline_commands=['multiline'],
                             aliases={
                                 'helpalias': 'help',
                                 '42': 'theanswer',
                                 'l': '!ls -al',
                                 'anothermultiline': 'multiline',
                                 'fake': 'pyscript'
                             },
                             shortcuts=[('?', 'help'), ('!', 'shell')])
    return parser
Beispiel #3
0
def parser():
    from cmd2.parsing import StatementParser
    parser = StatementParser(
        terminators=[';', '&'],
        multiline_commands=['multiline'],
        aliases={'helpalias': 'help',
                 '42': 'theanswer',
                 'l': '!ls -al',
                 'anothermultiline': 'multiline',
                 'fake': 'run_pyscript'},
        shortcuts={'?': 'help', '!': 'shell'}
    )
    return parser
Beispiel #4
0
def default_parser():
    parser = StatementParser()
    return parser