Skip to content

config_to_str outputs wrong values for !--no-flag on v2.2.0 #773

@Krpa

Description

@Krpa

Having only !--no-flag specified when adding an option or having it as the first name will result in wrong (reversed) config file outputs.
Steps to reproduce:

  1. Run with --no-flag. This results with setting the variable flag=false (correct), but it outputs no-flag=false.
  2. Save the output (no-flag=false) to config.toml
  3. Run with --config "path/to/config.toml". This results with flag=true and the output is no-flag=true.
#include <CLI11/CLI11.hpp>

#include <iostream>

int main()
{
  CLI::App app;
  bool flag;
  app.add_flag("!--no-flag", flag);
  app.set_config("--config,--ini");
  try {
    app.parse(argc, argv);
  } catch (const CLI::Error& e) {
    return app.exit(e);
  }

  std::cout << app.config_to_str(false, false) << std::endl;
  return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions