Skip to content

Commit

Permalink
cmd: fix CLI11 parse regression in snapshots utility (#1792)
Browse files Browse the repository at this point in the history
Using enumerated parameters with base type size different from int breaks CLI11 parsing with an error:

    --tool: Value  not in range
  • Loading branch information
canepat authored Feb 1, 2024
1 parent 2b8c773 commit 401c608
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ build*
venv
xcode
*.code-workspace
.DS_Store
.idea
.vscode
.vs
CMakeFiles
cmake-build-*
tests/integration/goerly/results

6 changes: 3 additions & 3 deletions cmd/dev/snapshots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ struct DownloadSettings : public bittorrent::BitTorrentSettings {
std::string magnet_uri;
};

//! The Snapshots tools
enum class SnapshotTool : uint8_t {
//! The available subcommands in snapshots utility
//! \warning reducing the enum base type size as suggested by clang-tidy breaks CLI11
enum class SnapshotTool { // NOLINT(performance-enum-size)
count_bodies,
count_headers,
create_index,
Expand Down Expand Up @@ -133,7 +134,6 @@ void parse_command_line(int argc, char* argv[], CLI::App& app, SnapshotToolboxSe
{"sync", SnapshotTool::sync},
};
app.add_option("--tool", settings.tool, "The snapshot tool to use")
->capture_default_str()
->check(CLI::Range(SnapshotTool::count_bodies, SnapshotTool::sync))
->transform(CLI::Transformer(snapshot_tool_mapping, CLI::ignore_case))
->default_val(SnapshotTool::download);
Expand Down

0 comments on commit 401c608

Please sign in to comment.