Skip to content

Commit

Permalink
feat: Add CPLIB_STARTUP_TEXT macro
Browse files Browse the repository at this point in the history
  • Loading branch information
yzy-1 committed Aug 3, 2024
1 parent 44c4dfc commit cfe5ce6
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
4 changes: 4 additions & 0 deletions docs/pages/user-guide/advanced/initializer.en.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,7 @@ If the `<name>` type is Reader, an additional parameter representing the Reader'
<Callout type="warning">
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.
</Callout>

<Callout type="warning">
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.
</Callout>
4 changes: 4 additions & 0 deletions docs/pages/user-guide/advanced/initializer.zh.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,7 @@ Initializer 需继承自 `cplib::<work-modeInitializerReporter` 并实现 `auto
<Callout type="warning">
不要在实现 `Reporter::report` 的时候通过调用 `cplib::panic` 函数报告错误.因为 CPLib 程序在初始化的时候会将 panic 实现修改为以 INTERNAL_ERROR 作为 status 调用 `Reporter::report`.这会引起无限递归.
</Callout>

<Callout type="warning">
根据 LGPL 许可证要求,当你分发使用 CPLib 的软件时,你需要在某处说明该软件使用 CPLib,并且 CPLib 是 LGPL 许可的.我们推荐的方式是在命令行参数包含 `--help` 时输出有关信息.本教程为保证代码简短并未做出实现,在实际项目中请务必注意严格遵守开源许可证.
</Callout>
4 changes: 1 addition & 3 deletions include/checker.i.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions include/generator.i.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ inline auto parse_arg(std::string_view arg) -> std::pair<std::string, std::optio

inline auto print_help_message(std::string_view program_name, std::string_view args_usage) -> 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"
Expand Down
4 changes: 1 addition & 3 deletions include/interactor.i.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ constexpr std::string_view ARGS_USAGE = "<input_file> [--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"
Expand Down
5 changes: 5 additions & 0 deletions include/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions include/validator.i.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,7 @@ constexpr std::string_view ARGS_USAGE = "[<input_file>] [--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"
Expand Down

0 comments on commit cfe5ce6

Please sign in to comment.