1
0

feat: finish summary and application for clap.

- finish summary and application for clap.
- add patch for utf8 string in std::format.
This commit is contained in:
2025-09-24 16:20:21 +08:00
parent 776adb0c96
commit a61955bb09
8 changed files with 203 additions and 2 deletions

View File

@ -1,5 +1,6 @@
#include "option.hpp"
#include "../../string/op.hpp"
#include "../../string/format.hpp"
#include <stdexcept>
#include <format>
@ -117,7 +118,8 @@ namespace yycc::carton::clap::option {
if (short_name.has_value()) {
std::u8string short_name_value(short_name.value());
if (this->long_names.contains(short_name_value)) {
throw std::logic_error(std::format("short name {} is duplicated with same long name", short_name_value));
throw std::logic_error(
std::format("short name {} is duplicated with same long name", short_name_value));
}
auto [_, ok] = this->short_names.try_emplace(short_name_value, token);
if (!ok) {
@ -128,7 +130,8 @@ namespace yycc::carton::clap::option {
if (long_name.has_value()) {
std::u8string long_name_value(long_name.value());
if (this->short_names.contains(long_name_value)) {
throw std::logic_error(std::format("long name {} is duplicated with same short name", long_name_value));
throw std::logic_error(
std::format("long name {} is duplicated with same short name", long_name_value));
}
auto [_, ok] = this->long_names.try_emplace(long_name_value, token);
if (!ok) {