106f6ba60Sopenharmony_ci/*
206f6ba60Sopenharmony_ci * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
306f6ba60Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
406f6ba60Sopenharmony_ci * you may not use this file except in compliance with the License.
506f6ba60Sopenharmony_ci * You may obtain a copy of the License at
606f6ba60Sopenharmony_ci *
706f6ba60Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
806f6ba60Sopenharmony_ci *
906f6ba60Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1006f6ba60Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1106f6ba60Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1206f6ba60Sopenharmony_ci * See the License for the specific language governing permissions and
1306f6ba60Sopenharmony_ci * limitations under the License.
1406f6ba60Sopenharmony_ci */
1506f6ba60Sopenharmony_ci
1606f6ba60Sopenharmony_ci#ifndef COMMAND_LINE_H
1706f6ba60Sopenharmony_ci#define COMMAND_LINE_H
1806f6ba60Sopenharmony_ci
1906f6ba60Sopenharmony_ci#include <vector>
2006f6ba60Sopenharmony_ci#include <map>
2106f6ba60Sopenharmony_ci#include <memory>
2206f6ba60Sopenharmony_ci#include "command_param.h"
2306f6ba60Sopenharmony_ci
2406f6ba60Sopenharmony_ci#ifdef VT100_ENABLE
2506f6ba60Sopenharmony_ci#define VT100_RED "\033[31m"
2606f6ba60Sopenharmony_ci#define VT100_GREEN "\033[32m"
2706f6ba60Sopenharmony_ci#define VT100_YELLOW "\033[33m"
2806f6ba60Sopenharmony_ci#define VT100_BLUE "\033[34m"
2906f6ba60Sopenharmony_ci#define VT100_PURPLE "\033[35m"
3006f6ba60Sopenharmony_ci#define VT100_CYAN "\033[36m"
3106f6ba60Sopenharmony_ci#define VT100_WHITE "\033[37m"
3206f6ba60Sopenharmony_ci
3306f6ba60Sopenharmony_ci#define VT100_CLOSE "\033[0m"
3406f6ba60Sopenharmony_ci#define VT100_BRIGHT "\033[1m"
3506f6ba60Sopenharmony_ci#define VT100_UNDERLINE "\033[4m"
3606f6ba60Sopenharmony_ci#define VT100_FLASH "\033[5m"
3706f6ba60Sopenharmony_ci#else
3806f6ba60Sopenharmony_ci#define VT100_RED ""
3906f6ba60Sopenharmony_ci#define VT100_GREEN ""
4006f6ba60Sopenharmony_ci#define VT100_YELLOW ""
4106f6ba60Sopenharmony_ci#define VT100_BLUE ""
4206f6ba60Sopenharmony_ci#define VT100_PURPLE ""
4306f6ba60Sopenharmony_ci#define VT100_CYAN ""
4406f6ba60Sopenharmony_ci#define VT100_WHITE ""
4506f6ba60Sopenharmony_ci
4606f6ba60Sopenharmony_ci#define VT100_CLOSE ""
4706f6ba60Sopenharmony_ci#define VT100_BRIGHT ""
4806f6ba60Sopenharmony_ci#define VT100_UNDERLINE ""
4906f6ba60Sopenharmony_ci#define VT100_FLASH ""
5006f6ba60Sopenharmony_ci#endif
5106f6ba60Sopenharmony_ci
5206f6ba60Sopenharmony_ciclass CommandLine {
5306f6ba60Sopenharmony_cipublic:
5406f6ba60Sopenharmony_ci    static CommandLine& GetInstance();
5506f6ba60Sopenharmony_ci
5606f6ba60Sopenharmony_ci    int AnalyzeParam(std::vector<std::string> argv);
5706f6ba60Sopenharmony_ci
5806f6ba60Sopenharmony_ci    void AddParamSwitch(const std::string& filter1, const std::string& filter2, bool &pbool, const std::string& desc);
5906f6ba60Sopenharmony_ci    void AddParamText(const std::string& filter1,
6006f6ba60Sopenharmony_ci                      const std::string& filter2,
6106f6ba60Sopenharmony_ci                      std::string& pstr,
6206f6ba60Sopenharmony_ci                      const std::string& desc);
6306f6ba60Sopenharmony_ci
6406f6ba60Sopenharmony_ci    void PrintHelp();
6506f6ba60Sopenharmony_ci
6606f6ba60Sopenharmony_ciprivate:
6706f6ba60Sopenharmony_ci    CommandLine();
6806f6ba60Sopenharmony_ci    ~CommandLine();
6906f6ba60Sopenharmony_ci
7006f6ba60Sopenharmony_ci    int paramIdx_;
7106f6ba60Sopenharmony_ci    std::map<uint32_t, std::shared_ptr<CommandParam>> commandParams_;
7206f6ba60Sopenharmony_ci
7306f6ba60Sopenharmony_ci    int CheckParam(const std::string& s1, const std::string& s2);
7406f6ba60Sopenharmony_ci};
7506f6ba60Sopenharmony_ci
7606f6ba60Sopenharmony_ci#endif