MCPcopy Create free account
hub / github.com/apple/foundationdb / fdbcliCompCmd

Function fdbcliCompCmd

fdbcli/fdbcli.actor.cpp:807–858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

805}
806
807void fdbcliCompCmd(std::string const& text, std::vector<std::string>& lc) {
808 bool err, partial;
809 std::string whole_line = text;
810 auto parsed = parseLine(whole_line, err, partial);
811 if (err || partial) // If there was an error, or we are partially through a quoted sequence
812 return;
813
814 auto tokens = parsed.back();
815 int count = tokens.size();
816
817 // for(int i = 0; i < count; i++) {
818 // printf("Token (%d): `%s'\n", i, tokens[i].toString().c_str());
819 // }
820
821 std::string ntext = "";
822 std::string base_input = text;
823
824 // If there is a token and the input does not end in a space
825 if (count && text.size() > 0 && text[text.size() - 1] != ' ') {
826 count--; // Ignore the last token for purposes of later code
827 ntext = tokens.back().toString();
828 base_input = whole_line.substr(0, whole_line.rfind(ntext));
829 }
830
831 // printf("final text (%d tokens): `%s' & `%s'\n", count, base_input.c_str(), ntext.c_str());
832
833 if (!count) {
834 cmdGenerator(ntext.c_str(), lc);
835 return;
836 }
837
838 if (tokencmp(tokens[0], "help") && count == 1) {
839 helpGenerator(ntext.c_str(), lc);
840 return;
841 }
842
843 if (tokencmp(tokens[0], "option")) {
844 if (count == 1)
845 onOffGenerator(ntext.c_str(), base_input.c_str(), lc);
846 if (count == 2)
847 optionGenerator(ntext.c_str(), base_input.c_str(), lc);
848 }
849
850 if (tokencmp(tokens[0], "writemode") && count == 1) {
851 onOffGenerator(ntext.c_str(), base_input.c_str(), lc);
852 }
853
854 auto itr = CommandFactory::completionGenerators().find(tokens[0].toString());
855 if (itr != CommandFactory::completionGenerators().end()) {
856 itr->second(ntext.c_str(), base_input.c_str(), lc, tokens);
857 }
858}
859
860void LogCommand(std::string line, UID randomID, std::string errMsg) {
861 printf("%s\n", errMsg.c_str());

Callers 1

Future<int> runCliFunction · 0.85

Calls 14

cmdGeneratorFunction · 0.85
tokencmpFunction · 0.85
helpGeneratorFunction · 0.85
onOffGeneratorFunction · 0.85
optionGeneratorFunction · 0.85
substrMethod · 0.80
parseLineFunction · 0.70
backMethod · 0.45
sizeMethod · 0.45
toStringMethod · 0.45
c_strMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected