MCPcopy Create free account
hub / github.com/baidu/tera / main

Function main

src/admincli.cc:1933–1997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1931}
1932
1933int main(int argc, char* argv[]) {
1934 FLAGS_minloglevel = 2;
1935 ::google::ParseCommandLineFlags(&argc, &argv, true);
1936
1937 if (argc > 1 && std::string(argv[1]) == "version") {
1938 PrintSystemVersion();
1939 return 0;
1940 } else if (argc > 1 && std::string(argv[1]) == "help") {
1941 HelpOp(argc, argv);
1942 return 0;
1943 }
1944
1945 if (FLAGS_flagfile == "") {
1946 FLAGS_flagfile = "../conf/tera.flag";
1947 if (access(FLAGS_flagfile.c_str(), R_OK) != 0) {
1948 FLAGS_flagfile = "./tera.flag";
1949 }
1950 utils::LoadFlagFile(FLAGS_flagfile);
1951 }
1952 if (FLAGS_meta_cli_token != g_metacli_token) {
1953 std::cout << "Please figure out what metacli is before use it." << std::endl;
1954 return -1;
1955 }
1956
1957 Client* client = Client::NewClient(FLAGS_flagfile, NULL);
1958 if (client == NULL) {
1959 LOG(ERROR) << "client instance not exist";
1960 return -1;
1961 }
1962
1963 InitializeCommandTable();
1964
1965 CliStatus ret = CliStatus::kOk;
1966 if (argc == 1) {
1967 char* line = NULL;
1968 while ((line = readline("meta> ")) != NULL) {
1969 char* line_copy = strdup(line);
1970 std::vector<char*> arg_list;
1971 arg_list.push_back(argv[0]);
1972 char* tmp = NULL;
1973 char* token = strtok_r(line, " \t", &tmp);
1974 while (token != NULL) {
1975 arg_list.push_back(token);
1976 token = strtok_r(NULL, " \t", &tmp);
1977 }
1978 if (arg_list.size() == 2 &&
1979 (strcmp(arg_list[1], "quit") == 0 || strcmp(arg_list[1], "exit") == 0)) {
1980 free(line_copy);
1981 free(line);
1982 break;
1983 }
1984 if (arg_list.size() > 1) {
1985 add_history(line_copy);
1986 ret = ExecuteCommand(client, arg_list.size(), &arg_list[0]);
1987 }
1988 free(line_copy);
1989 free(line);
1990 }

Callers

nothing calls this directly

Calls 6

LoadFlagFileFunction · 0.85
push_backMethod · 0.80
HelpOpFunction · 0.70
InitializeCommandTableFunction · 0.70
ExecuteCommandFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected