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')
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
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
def default_parser(): parser = StatementParser() return parser