Skip to content

Commit 154f78b

Browse files
authored
Merge pull request #1 from SvenGroot/v2.0.2-dev
Merge v2.0.2 into main
2 parents 41ddd0e + 873a415 commit 154f78b

File tree

10 files changed

+65
-42
lines changed

10 files changed

+65
-42
lines changed

.github/workflows/cmake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ${{ matrix.os }}
2323

2424
steps:
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2626

2727
- name: Install Package
2828
# You may pin to the exact commit or the version.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include(CMakePackageConfigHelpers)
44

55
project (
66
"Ookii.CommandLine.Cpp"
7-
VERSION 2.0.0
7+
VERSION 2.0.2
88
HOMEPAGE_URL "https://github.com/SvenGroot/Ookii.CommandLine.Cpp"
99
LANGUAGES CXX)
1010

docs/ChangeLog.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
# What's new in Ookii.CommandLine for C++
22

3-
## Ookii.CommandLine for C++ 2.0.1
3+
## Ookii.CommandLine for C++ 2.0.2 (2025-05-13)
4+
5+
- Fix compilation errors affecting the unit tests with recent versions of Visual Studio 2022.
6+
- There is a small chance this could affect your code if you were using certain helper functions
7+
defined in the `format_helper.h` header directly (they are otherwise not used outside the unit
8+
tests).
9+
10+
## Ookii.CommandLine for C++ 2.0.1 (2023-10-11)
411

512
- Fix the description of the NuGet package.
613
- This release is NuGet-only and does not contain any other changes. The project version number has
714
not changed; only the NuGet package version.
815

9-
## Ookii.CommandLine for C++ 2.0
16+
## Ookii.CommandLine for C++ 2.0 (2023-01-12)
1017

1118
- Argument parsing
1219
- Added support for a [new parsing mode](Arguments.md#longshort-mode) where arguments can have a
@@ -33,7 +40,8 @@
3340
list ordering and filtering, the ability to override any string or format, and more.
3441
- Arguments that have no description but that have other information not shown in the usage syntax
3542
(like aliases or a default value) will be included in the description list by default.
36-
- [`line_wrapping_ostream`][] has an option to flush all content, including the last unfinished line.
43+
- [`line_wrapping_ostream`][] has an option to flush all content, including the last unfinished
44+
line.
3745
- Added [`line_wrapping_ostringstream`][] class.
3846
- [Code generation](Scripts.md) supports the new functionality.
3947
- Updated and improved documentation.
@@ -45,24 +53,26 @@ There are a number of breaking API changes from version 1.0:
4553

4654
- The callback used by [`command_line_parser::on_parsed()`][] takes an [`std::optional<std::string_view>`][]
4755
for the value, instead of just [`std::string_view`][].
48-
- The [`command_line_parser::get_argument()`][command_line_parser::get_argument()_0] method returns `nullptr` instead of throwing an
49-
exception for a non-existent argument.
56+
- The [`command_line_parser::get_argument()`][command_line_parser::get_argument()_0] method returns
57+
`nullptr` instead of throwing an exception for a non-existent argument.
5058
- Default values for arguments are now displayed with stream insertion ([`operator<<`][]), so custom
5159
types must define that instead of a formatter.
52-
- The `for_each_argument_in_usage_order()` method has been removed; the [`arguments()`][] method returns
53-
the arguments in that order.
60+
- The `for_each_argument_in_usage_order()` method has been removed; the [`arguments()`][] method
61+
returns the arguments in that order.
5462
- The `<shell_command.h>` header was renamed to `<subcommand.h>`.
5563
- Recommended: include `<command_line.h>` instead; it now includes subcommands.
5664
- The `shell_command` class was renamed to [`command`][].
5765
- The `shell_command_manager` class was renamed to [`command_manager`][].
58-
- Several overloads of the [`create_command()`][create_command()_0] and [`run_command()`][run_command()_2] methods have been removed. This
59-
was necessary to support commands with custom argument parsing.
60-
- The [`command_manager::run_command()`][command_manager::run_command()_1] method returns an [`std::optional<int>`][].
66+
- Several overloads of the [`create_command()`][create_command()_0] and
67+
[`run_command()`][run_command()_2] methods have been removed. This was necessary to support
68+
commands with custom argument parsing.
69+
- The [`command_manager::run_command()`][command_manager::run_command()_1] method returns an
70+
[`std::optional<int>`][].
6171
- Several changes to the code generation scripts mean that any generated files must be regenerated.
62-
- The `OOKII_DECLARE_PARSE_METHOD()` macro has been replaced with the [`OOKII_GENERATED_METHODS()`][]
63-
macro.
72+
- The `OOKII_DECLARE_PARSE_METHOD()` macro has been replaced with the
73+
[`OOKII_GENERATED_METHODS()`][] macro.
6474

65-
## Ookii.CommandLine for C++ 1.0
75+
## Ookii.CommandLine for C++ 1.0 (2022-10-23)
6676

6777
- Initial release
6878
- Feature parity with [Ookii.CommandLine 2.4 for .Net](https://github.com/SvenGroot/Ookii.CommandLine),

docs/Tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ set(CMAKE_CXX_STANDARD 20)
2929
3030
FetchContent_Declare(OOKIICL
3131
GIT_REPOSITORY "https://github.com/SvenGroot/Ookii.CommandLine.Cpp"
32-
GIT_TAG "v2.0")
32+
GIT_TAG "v2.0.2")
3333
3434
FetchContent_MakeAvailable(OOKIICL)
3535

include/ookii/format_helper.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ namespace ookii::format
5252
//! \param args The arguments
5353
//! \return The formatted string.
5454
template<typename... Args>
55-
std::string ncformat(const std::locale &loc, std::string_view format, Args&&... args)
55+
std::string ncformat(const std::locale &loc, std::string_view format, Args&... args)
5656
{
57-
return OOKII_FMT_NS vformat(loc, format, OOKII_FMT_NS make_format_args(std::forward<Args>(args)...));
57+
return OOKII_FMT_NS vformat(loc, format, OOKII_FMT_NS make_format_args(args...));
5858
}
5959

6060
//! \brief Helper to format using a non-const format wide string without needing to explicitly
@@ -66,9 +66,9 @@ namespace ookii::format
6666
//! \param args The arguments
6767
//! \return The formatted string.
6868
template<typename... Args>
69-
std::wstring ncformat(const std::locale &loc, std::wstring_view format, Args&&... args)
69+
std::wstring ncformat(const std::locale &loc, std::wstring_view format, Args&... args)
7070
{
71-
return OOKII_FMT_NS vformat(loc, format, OOKII_FMT_NS make_format_args<OOKII_FMT_NS wformat_context>(std::forward<Args>(args)...));
71+
return OOKII_FMT_NS vformat(loc, format, OOKII_FMT_NS make_format_args<OOKII_FMT_NS wformat_context>(args...));
7272
}
7373
}
7474

include/ookii/vt_helper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "format_helper.h"
1111
#include <string_view>
1212
#include <locale>
13+
#include <cstring>
1314

1415
//! \brief Namespace containing functions and types for working with virtual terminal sequences.
1516
namespace ookii::vt
@@ -307,7 +308,7 @@ namespace ookii::vt
307308
#endif
308309

309310
// If "TERM=dumb" is set, assume no support.
310-
if (has_term && strcmp(term, "dumb") == 0)
311+
if (has_term && std::strcmp(term, "dumb") == 0)
311312
{
312313
return {};
313314
}

nuget/package/Ookii.CommandLine.Cpp.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
33
<metadata>
44
<id>Ookii.CommandLine.Cpp</id>
5-
<version>2.0.1</version>
5+
<version>2.0.2</version>
66
<title>Ookii.CommandLine for C++</title>
77
<authors>Sven Groot</authors>
88
<owners>Sven Groot</owners>

unittests/CommandLineParserTests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,8 @@ class CommandLineParserTests : public test::TestClass
966966
{
967967
if (expected_error != result.error)
968968
{
969-
test::LogMessage(test::LogMessageType::Error, TEXT("{}"), result.get_error_message());
969+
auto message = result.get_error_message();
970+
test::LogMessage(test::LogMessageType::Error, TEXT("{}"), message);
970971
}
971972

972973
VERIFY_EQUAL((int)expected_error, (int)result.error);

unittests/framework.h

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace details
5252
// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2508r1.html. The type is available
5353
// in libfmt.
5454
template<typename... Args>
55-
void LogMessagePart(LogMessageType type, const std::basic_string_view<tchar_t> format, Args&&... args)
55+
void LogMessagePart(LogMessageType type, const std::basic_string_view<tchar_t> format, Args&... args)
5656
{
5757
switch (type)
5858
{
@@ -81,16 +81,16 @@ namespace details
8181
break;
8282
}
8383

84-
tcout << format::ncformat({}, format, std::forward<Args>(args)...);
84+
tcout << format::ncformat({}, format, args...);
8585
}
8686

8787
}
8888

8989
template<typename... Args>
90-
void LogMessage(LogMessageType type, const std::basic_string_view<tchar_t> format, Args&&... args)
90+
void LogMessage(LogMessageType type, const std::basic_string_view<tchar_t> format, Args&... args)
9191
{
9292
std::lock_guard<std::mutex> lock{details::g_logMutex};
93-
details::LogMessagePart(type, format, std::forward<Args>(args)...);
93+
details::LogMessagePart(type, format, args...);
9494
tcout << std::endl;
9595
}
9696

@@ -246,7 +246,9 @@ class TestClass
246246
}
247247
catch (const std::exception &ex)
248248
{
249-
LogMessage(LogMessageType::Error, TEXT("Unexpected exception of type {}: {}"), get_type_name<tchar_t>(typeid(ex)), string_convert<tchar_t>::from_bytes(ex.what()));
249+
auto type = get_type_name<tchar_t>(typeid(ex));
250+
auto what = string_convert<tchar_t>::from_bytes(ex.what());
251+
LogMessage(LogMessageType::Error, TEXT("Unexpected exception of type {}: {}"), type, what);
250252
}
251253
catch (...)
252254
{
@@ -348,22 +350,26 @@ namespace details
348350
#define OOKII_TEST_THROW_FAILED_IF(condition) if (condition) { OOKII_TEST_THROW_FAILED(); }
349351

350352
template<typename... Args>
351-
void LogVerify(const VerifyInfo &info, bool success, std::basic_string_view<tchar_t> format, Args... args)
353+
void LogVerify(const VerifyInfo &info, bool success, std::basic_string_view<tchar_t> format, Args&... args)
352354
{
353355
auto olderrno = errno;
354356
std::lock_guard<std::mutex> lock{g_logMutex};
355357
if (success)
356358
{
357359
if (g_verbose)
358-
LogMessagePart(LogMessageType::Info, TEXT("{}:{}: Verify: "), string_convert<tchar_t>::from_bytes(info.FunctionName), info.Line);
360+
{
361+
auto functionName = string_convert<tchar_t>::from_bytes(info.FunctionName);
362+
LogMessagePart(LogMessageType::Info, TEXT("{}:{}: Verify: "), functionName, info.Line);
363+
}
359364
}
360365
else
361366
{
362-
LogMessagePart(LogMessageType::Error, TEXT("{}:{}: Failed: "), string_convert<tchar_t>::from_bytes(info.FunctionName), info.Line);
367+
auto functionName = string_convert<tchar_t>::from_bytes(info.FunctionName);
368+
LogMessagePart(LogMessageType::Error, TEXT("{}:{}: Failed: "), functionName, info.Line);
363369
}
364370

365371
if (!success || g_verbose)
366-
tcout << format::ncformat({}, format, std::forward<Args>(args)...) << std::endl;
372+
tcout << format::ncformat({}, format, args...) << std::endl;
367373

368374
errno = olderrno;
369375
}
@@ -471,9 +477,11 @@ namespace details
471477
using std::begin;
472478
using std::end;
473479
using std::size;
474-
if (size(expected) != size(actual))
480+
auto expectedSize = size(expected);
481+
auto actualSize = size(actual);
482+
if (expectedSize != actualSize)
475483
{
476-
LogVerify(info, false, TEXT("Range: {} == {} (size differs: {} != {})"), expectedName, actualName, size(expected), size(actual));
484+
LogVerify(info, false, TEXT("Range: {} == {} (size differs: {} != {})"), expectedName, actualName, expectedSize, actualSize);
477485
OOKII_TEST_THROW_FAILED();
478486
}
479487

@@ -482,14 +490,16 @@ namespace details
482490
{
483491
if (*item1 != *item2)
484492
{
493+
const auto& item1Ref = *item1;
494+
const auto& item2Ref = *item2;
485495
LogVerify(info, false, TEXT("Range: {} == {} (items at index {} differ: <{}> != <{}>)"), expectedName, actualName,
486-
index, *item1, *item2);
496+
index, item1Ref, item2Ref);
487497

488498
OOKII_TEST_THROW_FAILED();
489499
}
490500
}
491501

492-
LogVerify(info, true, TEXT("Range: {} == {} (size {})"), expectedName, actualName, size(expected));
502+
LogVerify(info, true, TEXT("Range: {} == {} (size {})"), expectedName, actualName, expectedSize);
493503
}
494504

495505
inline void VerifyUnexpectedException(const tchar_t *operation, const VerifyInfo &info)
@@ -504,8 +514,9 @@ namespace details
504514
}
505515
catch (const std::exception &ex)
506516
{
507-
LogVerify(info, false, TEXT("Operation {} threw unexpected exception {}: {}"), operation,
508-
get_type_name<tchar_t>(typeid(ex)), string_convert<tchar_t>::from_bytes(ex.what()));
517+
auto what = string_convert<tchar_t>::from_bytes(ex.what());
518+
auto type = get_type_name<tchar_t>(typeid(ex));
519+
LogVerify(info, false, TEXT("Operation {} threw unexpected exception {}: {}"), operation, type, what);
509520
}
510521
catch (...)
511522
{

unittests/unittests.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ END
5555
//
5656

5757
VS_VERSION_INFO VERSIONINFO
58-
FILEVERSION 2,0,0,0
59-
PRODUCTVERSION 2,0,0,0
58+
FILEVERSION 2,0,2,0
59+
PRODUCTVERSION 2,0,2,0
6060
FILEFLAGSMASK 0x3fL
6161
#ifdef _DEBUG
6262
FILEFLAGS 0x1L
@@ -73,12 +73,12 @@ BEGIN
7373
BEGIN
7474
VALUE "CompanyName", "Sven Groot (Ookii.org)"
7575
VALUE "FileDescription", "Unit tests for Ookii.CommandLine for C++"
76-
VALUE "FileVersion", "2.0.0.0"
76+
VALUE "FileVersion", "2.0.2.0"
7777
VALUE "InternalName", "unittests.rc"
7878
VALUE "LegalCopyright", "Copyright (C) Sven Groot (Ookii.org)"
7979
VALUE "OriginalFilename", "unittests.rc"
8080
VALUE "ProductName", "Ookii.CommandLine for C++"
81-
VALUE "ProductVersion", "2.0.0.0"
81+
VALUE "ProductVersion", "2.0.2.0"
8282
END
8383
END
8484
BLOCK "VarFileInfo"

0 commit comments

Comments
 (0)