migrated cli functions

This commit is contained in:
ativelkov 2014-01-24 17:26:26 -08:00
parent c16eb235f7
commit da36075653

View File

@ -18,20 +18,19 @@ import re
import types import types
from json import JSONDecoder from json import JSONDecoder
from yaql.context import Context from yaql.language.context import Context
from yaql.exceptions import YaqlParsingException from yaql.language.exceptions import YaqlParsingException
import yaql import yaql
from yaql.functions.old.decorators import arg, ContextAware
from yaql.language import lexer from yaql.language import lexer
from yaql.language.engine import context_aware
from yaql.language.utils import limit from yaql.language.utils import limit
PROMPT = "yaql> " PROMPT = "yaql> "
@ContextAware() @context_aware
@arg('show_tokens')
def main(context, show_tokens): def main(context, show_tokens):
print "Yet Another Query Language - command-line query tool" print "Yet Another Query Language - command-line query tool"
print "Copyright (c) 2013 Mirantis, Inc" print "Copyright (c) 2013 Mirantis, Inc"
@ -49,18 +48,18 @@ def main(context, show_tokens):
if not comm: if not comm:
continue continue
if comm[0] == '@': if comm[0] == '@':
funcName, args = parse_service_command(comm) func_name, args = parse_service_command(comm)
if funcName not in SERVICE_FUNCTIONS: if func_name not in SERVICE_FUNCTIONS:
print "Unknown command " + funcName print "Unknown command " + func_name
else: else:
SERVICE_FUNCTIONS[funcName](args, context) SERVICE_FUNCTIONS[func_name](args, context)
continue continue
try: try:
if show_tokens: if show_tokens:
lexer.input(comm) lexer.lexer.input(comm)
tokens = [] tokens = []
while True: while True:
tok = lexer.token() tok = lexer.lexer.token()
if not tok: if not tok:
break break
tokens.append(tok) tokens.append(tok)