From cfe5ce6eff8f2f911b183c9321237126424b9093 Mon Sep 17 00:00:00 2001 From: yzy-1 <50034950+yzy-1@users.noreply.github.com> Date: Sat, 3 Aug 2024 06:58:54 +0800 Subject: [PATCH] feat: Add CPLIB_STARTUP_TEXT macro --- docs/pages/user-guide/advanced/initializer.en.mdx | 4 ++++ docs/pages/user-guide/advanced/initializer.zh.mdx | 4 ++++ include/checker.i.hpp | 4 +--- include/generator.i.hpp | 4 +--- include/interactor.i.hpp | 4 +--- include/macros.hpp | 5 +++++ include/validator.i.hpp | 5 +---- 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/pages/user-guide/advanced/initializer.en.mdx b/docs/pages/user-guide/advanced/initializer.en.mdx index e8386d9..665f254 100644 --- a/docs/pages/user-guide/advanced/initializer.en.mdx +++ b/docs/pages/user-guide/advanced/initializer.en.mdx @@ -127,3 +127,7 @@ If the `` type is Reader, an additional parameter representing the Reader' Do not report errors by calling the `cplib::panic` function when implementing `Reporter::report`. This is because CPLib programs modify the panic implementation during initialization to call `Reporter::report` with `INTERNAL_ERROR` as the status, which will cause an infinite recursion. + + +According to the LGPL license requirements, when you distribute software that uses CPLib, you need to indicate somewhere that the software uses CPLib, and that CPLib is licensed under the LGPL. Our recommended approach is to output relevant information when the command line argument contains `--help`. This tutorial has not been implemented to keep the code short. In actual projects, please be sure to strictly abide by the open source license. + diff --git a/docs/pages/user-guide/advanced/initializer.zh.mdx b/docs/pages/user-guide/advanced/initializer.zh.mdx index 12d90db..fb2736e 100644 --- a/docs/pages/user-guide/advanced/initializer.zh.mdx +++ b/docs/pages/user-guide/advanced/initializer.zh.mdx @@ -127,3 +127,7 @@ Initializer 需继承自 `cplib:: 不要在实现 `Reporter::report` 的时候通过调用 `cplib::panic` 函数报告错误.因为 CPLib 程序在初始化的时候会将 panic 实现修改为以 INTERNAL_ERROR 作为 status 调用 `Reporter::report`.这会引起无限递归. + + + 根据 LGPL 许可证要求,当你分发使用 CPLib 的软件时,你需要在某处说明该软件使用 CPLib,并且 CPLib 是 LGPL 许可的.我们推荐的方式是在命令行参数包含 `--help` 时输出有关信息.本教程为保证代码简短并未做出实现,在实际项目中请务必注意严格遵守开源许可证. + diff --git a/include/checker.i.hpp b/include/checker.i.hpp index 5b97546..e55fe2e 100644 --- a/include/checker.i.hpp +++ b/include/checker.i.hpp @@ -205,9 +205,7 @@ constexpr std::string_view ARGS_USAGE = inline auto print_help_message(std::string_view program_name) -> void { std::string msg = - format("cplib (CPLib) " CPLIB_VERSION - "\n" - "https://github.com/rindag-devs/cplib/ by Rindag Devs, copyright(c) 2023\n" + format(CPLIB_STARTUP_TEXT "\n" "Usage:\n" " %s %s\n" diff --git a/include/generator.i.hpp b/include/generator.i.hpp index d8cc759..b634df2 100644 --- a/include/generator.i.hpp +++ b/include/generator.i.hpp @@ -118,9 +118,7 @@ inline auto parse_arg(std::string_view arg) -> std::pair void { std::string msg = - format("cplib (CPLib) " CPLIB_VERSION - "\n" - "https://github.com/rindag-devs/cplib/ by Rindag Devs, copyright(c) 2023\n" + format(CPLIB_STARTUP_TEXT "\n" "Usage:\n" " %s %s\n" diff --git a/include/interactor.i.hpp b/include/interactor.i.hpp index 052ccb4..d328c0b 100644 --- a/include/interactor.i.hpp +++ b/include/interactor.i.hpp @@ -180,9 +180,7 @@ constexpr std::string_view ARGS_USAGE = " [--report-format={auto|jso inline auto print_help_message(std::string_view program_name) -> void { std::string msg = - format("cplib (CPLib) " CPLIB_VERSION - "\n" - "https://github.com/rindag-devs/cplib/ by Rindag Devs, copyright(c) 2023\n" + format(CPLIB_STARTUP_TEXT "\n" "Usage:\n" " %s %s\n" diff --git a/include/macros.hpp b/include/macros.hpp index f09c77b..bdbfd26 100644 --- a/include/macros.hpp +++ b/include/macros.hpp @@ -18,6 +18,11 @@ #define CPLIB_VERSION "0.0.1-SNAPSHOT" +#define CPLIB_STARTUP_TEXT \ + "cplib (CPLib) " CPLIB_VERSION \ + "\n" \ + "https://github.com/rindag-devs/cplib/ by Rindag Devs, copyright(c) 2023-2024\n" + #if (_WIN32 || __WIN32__ || __WIN32 || _WIN64 || __WIN64__ || __WIN64 || WINNT || __WINNT || \ __WINNT__ || __CYGWIN__) #if !defined(_MSC_VER) || _MSC_VER > 1400 diff --git a/include/validator.i.hpp b/include/validator.i.hpp index 2501254..7b2b334 100644 --- a/include/validator.i.hpp +++ b/include/validator.i.hpp @@ -286,10 +286,7 @@ constexpr std::string_view ARGS_USAGE = "[] [--report-format={auto|j inline auto print_help_message(std::string_view program_name) -> void { std::string msg = - format("cplib (CPLib) " CPLIB_VERSION - "\n" - "https://github.com/rindag-devs/cplib/ by Rindag Devs, copyright(c) 2023\n" - "\n" + format(CPLIB_STARTUP_TEXT "Usage:\n" " %s %s\n" "\n"