Skip to content

Commit

Permalink
Fix CLI11 migration to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
elshize committed Oct 7, 2023
1 parent b7531fe commit c990a1a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
9 changes: 6 additions & 3 deletions tools/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ auto Index::index_filename() const -> std::string const&

Analyzer::Analyzer(CLI::App* app)
{
app->add_option("--tokenizer", m_tokenizer, "Tokenizer", true)
app->add_option("--tokenizer", m_tokenizer, "Tokenizer")
->capture_default_str()
->check(CLI::IsMember(VALID_TOKENIZERS));
app->add_option("-H,--html", m_strip_html, "Strip HTML", true);
app->add_option("-H,--html", m_strip_html, "Strip HTML")->capture_default_str();
app->add_option("-F,--token-filters", m_token_filters, "Token filters")
->check(CLI::IsMember(VALID_TOKEN_FILTERS));
app->add_option(
Expand Down Expand Up @@ -71,7 +72,9 @@ const std::set<std::string> Analyzer::VALID_TOKEN_FILTERS = {"lowercase", "porte

LogLevel::LogLevel(CLI::App* app)
{
app->add_option("-L,--log-level", m_level, "Log level", true)->check(CLI::IsMember(VALID_LEVELS));
app->add_option("-L,--log-level", m_level, "Log level")
->capture_default_str()
->check(CLI::IsMember(VALID_LEVELS));
}

auto LogLevel::log_level() const -> spdlog::level::level_enum
Expand Down
7 changes: 4 additions & 3 deletions tools/app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ namespace arg {
struct Query: public Analyzer {
explicit Query(CLI::App* app) : Analyzer(app)
{
app->add_option("-q,--queries", m_query_file, "Path to file with queries", false);
app->add_option("-q,--queries", m_query_file, "Path to file with queries")
->capture_default_str();
m_terms_option = app->add_option("--terms", m_term_lexicon, "Term lexicon");
app->add_flag("--weighted", m_weighted, "Weights scores by query frequency");
if constexpr (Mode == QueryMode::Ranked) {
Expand Down Expand Up @@ -247,8 +248,8 @@ namespace arg {
struct BatchSize {
explicit BatchSize(CLI::App* app)
{
app->add_option(
"--batch-size", m_batch_size, "Number of documents to process at a time", true);
app->add_option("--batch-size", m_batch_size, "Number of documents to process at a time")
->capture_default_str();
}

[[nodiscard]] auto batch_size() const -> std::size_t { return m_batch_size; }
Expand Down
6 changes: 3 additions & 3 deletions tools/parse_collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ int main(int argc, char** argv)
app.add_option("-o,--output", output_filename, "Forward index filename")
->required()
->check(valid_basename);
app.add_option(
"-b,--batch-size", batch_size, "Number of documents to process in one thread", true);
app.add_option("-f,--format", format, "Input format", true);
app.add_option("-b,--batch-size", batch_size, "Number of documents to process in one thread")
->capture_default_str();
app.add_option("-f,--format", format, "Input format")->capture_default_str();

size_t batch_count, document_count;
CLI::App* merge_cmd = app.add_subcommand(
Expand Down

0 comments on commit c990a1a

Please sign in to comment.