1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef COMMAND_LINE_H 17 #define COMMAND_LINE_H 18 19 #include <vector> 20 #include <map> 21 #include <memory> 22 #include "command_param.h" 23 24 #ifdef VT100_ENABLE 25 #define VT100_RED "\033[31m" 26 #define VT100_GREEN "\033[32m" 27 #define VT100_YELLOW "\033[33m" 28 #define VT100_BLUE "\033[34m" 29 #define VT100_PURPLE "\033[35m" 30 #define VT100_CYAN "\033[36m" 31 #define VT100_WHITE "\033[37m" 32 33 #define VT100_CLOSE "\033[0m" 34 #define VT100_BRIGHT "\033[1m" 35 #define VT100_UNDERLINE "\033[4m" 36 #define VT100_FLASH "\033[5m" 37 #else 38 #define VT100_RED "" 39 #define VT100_GREEN "" 40 #define VT100_YELLOW "" 41 #define VT100_BLUE "" 42 #define VT100_PURPLE "" 43 #define VT100_CYAN "" 44 #define VT100_WHITE "" 45 46 #define VT100_CLOSE "" 47 #define VT100_BRIGHT "" 48 #define VT100_UNDERLINE "" 49 #define VT100_FLASH "" 50 #endif 51 52 class CommandLine { 53 public: 54 static CommandLine& GetInstance(); 55 56 int AnalyzeParam(std::vector<std::string> argv); 57 58 void AddParamSwitch(const std::string& filter1, const std::string& filter2, bool &pbool, const std::string& desc); 59 void AddParamText(const std::string& filter1, 60 const std::string& filter2, 61 std::string& pstr, 62 const std::string& desc); 63 64 void PrintHelp(); 65 66 private: 67 CommandLine(); 68 ~CommandLine(); 69 70 int paramIdx_; 71 std::map<uint32_t, std::shared_ptr<CommandParam>> commandParams_; 72 73 int CheckParam(const std::string& s1, const std::string& s2); 74 }; 75 76 #endif