使help中的选项按添加顺序输出
This commit is contained in:
@@ -47,6 +47,8 @@ namespace ling {
|
||||
|
||||
//预定义参数规则
|
||||
std::unordered_map<std::string, DataStruct> data;
|
||||
//用来生成帮助的数据
|
||||
std::vector<DataStruct> helpData;
|
||||
//匿名参数数量
|
||||
int anonymityNumber = 0;
|
||||
int nextID = 1;
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace ling {
|
||||
const int id = nextID++;
|
||||
for (const auto &in: opt)
|
||||
data[in] = DataStruct(opt, id, type, message);
|
||||
|
||||
helpData.emplace_back(opt, id, type, message);
|
||||
if (type == OPT)
|
||||
options[id] = false;
|
||||
return {id, this};
|
||||
@@ -152,18 +152,18 @@ namespace ling {
|
||||
std::stringstream stream;
|
||||
stream << title << std::endl;
|
||||
std::cout << std::endl;
|
||||
for (const auto &[fst, snd]: data) {
|
||||
for (const auto &in: helpData) {
|
||||
std::stringstream temp;
|
||||
//即使参数有多个选项,也只输出前两个
|
||||
if (snd.options.size() == 2) {
|
||||
temp << std::left << std::setw(7) << (snd.options[0] + ",") << std::left << std::setw(18) << snd.options[1];
|
||||
if (in.options.size() == 2) {
|
||||
temp << std::left << std::setw(7) << (in.options[0] + ",") << std::left << std::setw(18) << in.options[1];
|
||||
} else {
|
||||
if (snd.options[0].at(0) == '-' && snd.options[0].at(1) == '-')
|
||||
temp << std::left << std::setw(7) << "" << std::left << std::setw(18) << snd.options[0];
|
||||
if (in.options[0].at(0) == '-' && in.options[0].at(1) == '-')
|
||||
temp << std::left << std::setw(7) << "" << std::left << std::setw(18) << in.options[0];
|
||||
else
|
||||
temp << std::left << std::setw(25) << snd.options[0];
|
||||
temp << std::left << std::setw(25) << in.options[0];
|
||||
}
|
||||
temp << std::left << std::setw(55) << snd.memage;
|
||||
temp << std::left << std::setw(55) << in.memage;
|
||||
stream << temp.str() << std::endl;
|
||||
}
|
||||
return stream.str();
|
||||
|
||||
Reference in New Issue
Block a user