From: Sebastian Harl Date: Sat, 2 Aug 2014 20:52:25 +0000 (+0200) Subject: frontend/grammar: Changed ‘LIST …’ to ‘LIST hosts …’. X-Git-Tag: sysdb-0.4.0~43 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8014e0bb085059cc026a129fc9f09de8435f17ed;p=sysdb.git frontend/grammar: Changed ‘LIST …’ to ‘LIST hosts …’. This seems more consistent. --- diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index a2ae448..3ece01a 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -201,7 +201,7 @@ statement: ; /* - * FETCH ; + * FETCH [FILTER ]; * * Retrieve detailed information about a single host. */ @@ -218,17 +218,29 @@ fetch_statement: ; /* - * LIST; + * LIST [FILTER ]; * * Returns a list of all hosts in the store. */ list_statement: - LIST filter_clause + LIST IDENTIFIER filter_clause { + /* TODO: support other types as well */ + if (strcasecmp($2, "hosts")) { + char errmsg[strlen($2) + 32]; + snprintf(errmsg, sizeof(errmsg), + YY_("unknown data-source %s"), $2); + sdb_fe_yyerror(&yylloc, scanner, errmsg); + free($2); $2 = NULL; + sdb_object_deref(SDB_OBJ($3)); + YYABORT; + } + $$ = SDB_CONN_NODE(sdb_object_create_dT(/* name = */ NULL, conn_list_t, conn_list_destroy)); - CONN_LIST($$)->filter = CONN_MATCHER($2); + CONN_LIST($$)->filter = CONN_MATCHER($3); $$->cmd = CONNECTION_LIST; + free($2); $2 = NULL; } ; diff --git a/t/integration/simple_query.sh b/t/integration/simple_query.sh index 86ac03f..942b77c 100755 --- a/t/integration/simple_query.sh +++ b/t/integration/simple_query.sh @@ -54,7 +54,7 @@ echo "$output" | grep "Failed to parse query 'INVALID'" echo "$output" | grep "parse error: syntax error" # Simple, successful commands. -output="$( run_sysdb -H "$SOCKET_FILE" -c LIST )" +output="$( run_sysdb -H "$SOCKET_FILE" -c 'LIST hosts' )" echo "$output" \ | grep -F '"host1.example.com"' \ | grep -F '"host2.example.com"' \ @@ -62,7 +62,7 @@ echo "$output" \ | grep -F '"other.host.name"' \ | grep -F '"some.host.name"' -output="$( echo 'LIST;' | run_sysdb -H "$SOCKET_FILE" )" || echo $? +output="$( echo 'LIST hosts;' | run_sysdb -H "$SOCKET_FILE" )" || echo $? echo "$output" \ | grep -F '"host1.example.com"' \ | grep -F '"host2.example.com"' \ @@ -80,7 +80,7 @@ echo "$output" | grep -F 'localhost' && exit 1 echo "$output" | grep -F 'other.host.name' && exit 1 echo "$output" | grep -F 'some.host.name' && exit 1 -(echo 'LIST;'; sleep 1; echo "FETCH 'host1.example.com'") \ +(echo 'LIST hosts;'; sleep 1; echo "FETCH 'host1.example.com'") \ | run_sysdb -H "$SOCKET_FILE" # When requesting information for unknown hosts, expect a non-zero exit code. diff --git a/t/unit/frontend/parser_test.c b/t/unit/frontend/parser_test.c index bca8645..16f61af 100644 --- a/t/unit/frontend/parser_test.c +++ b/t/unit/frontend/parser_test.c @@ -56,11 +56,11 @@ START_TEST(test_parse) { "FETCH 'host' FILTER " "host = 'host'", -1, 1, CONNECTION_FETCH }, - { "LIST", -1, 1, CONNECTION_LIST }, - { "LIST -- comment", -1, 1, CONNECTION_LIST }, - { "LIST;", -1, 1, CONNECTION_LIST }, - { "LIST; INVALID", 5, 1, CONNECTION_LIST }, - { "LIST FILTER " + { "LIST hosts", -1, 1, CONNECTION_LIST }, + { "LIST hosts -- foo", -1, 1, CONNECTION_LIST }, + { "LIST hosts;", -1, 1, CONNECTION_LIST }, + { "LIST hosts; INVALID", 11, 1, CONNECTION_LIST }, + { "LIST hosts FILTER " "host = 'host'", -1, 1, CONNECTION_LIST }, { "LOOKUP hosts", -1, 1, CONNECTION_LOOKUP }, @@ -190,6 +190,7 @@ START_TEST(test_parse) { "LIST; INVALID", 8, -1, 0 }, { "/* some incomplete", -1, -1, 0 }, + { "LIST", -1, -1, 0 }, { "LIST MATCHING " "host = 'host'", -1, -1, 0 }, { "FETCH 'host' MATCHING "