- 
                Notifications
    
You must be signed in to change notification settings  - Fork 397
 
Closed
Description
I do this:
cmd->add_option("--existing", "What to do if deployment already exists in the destination")
      ->transform(CLI::CheckedTransformer(std::unordered_map<std::string, ExistingBehaviour>{
          {"abort"s, ExistingBehaviour::abort},
          {"overwrite"s, ExistingBehaviour ::overwrite},
          {"delete"s, ExistingBehaviour::remove},
          {"remove"s, ExistingBehaviour::remove}}))
      ->default_val("abort");and all is well, the transformer runs but later (in a subcommand callback) I do:
cmd->get_option("--existing")->as<ExistingBehaviour>()And it throws.
It turns out that, even though the transformer runs, the original default ("abort") is stored instead of (apparently expected) "0". If I actually provide "--existing=abort" on the command line, it works. I could just put "0" as default but then a) help is broken, b) if I change the enum the hell breaks loose.
It looks to me like this function is responsible:
Lines 973 to 980 in 8ecce8f
| Option *default_val(std::string val) { | |
| default_str(val); | |
| auto old_results = results_; | |
| results_ = {val}; | |
| run_callback(); | |
| results_ = std::move(old_results); | |
| return this; | |
| } | 
Metadata
Metadata
Assignees
Labels
No labels