Skip to content

Enum help string formatting #554

@tomazsustar

Description

@tomazsustar

I used the example code to be able to enter a parameter as a number or as enum string.

std::map<std::string, FirmwareUpdateBase::FirmwareUpdateFlags> flagsMap{
        { "normal", normal },                
        { "allow_downgrade", allow_downgrade },          
        { "force_update", force_update},            
        { "no_check", no_check},                 
        { "normal_check_only", normal_check_only},         
        { "allow_downgrade_check_only", allow_downgrade_check_only}, 
        { "force_update_check_only", force_update_check_only }
    };
    app.add_option("--flags", flags_, "FW Update Flags")->default_val(normal)->transform(CLI::CheckedTransformer(flagsMap));

However the formatting of the help string is not very clear. All values are displayed in one raw, which is than broken by the width console of the window and is hard to read.

Options:
 -h,--help                   Print this help message and exit
 --flags ENUM:value in {allow_downgrade->1,allow_downgrade_check_only->5,force_update->2,force_update_check_only->6,no_
check->3,normal->0,normal_check_only->4} OR {1,5,2,6,3,0,4}=0
                             FW Update Flags

Would it be possible to display enum options in separate lines? Something like below? This would make the help output much more useful.

Options:
 -h,--help                   Print this help message and exit
 --flags ENUM:value in {
       allow_downgrade->1,
       allow_downgrade_check_only->5,
       force_update->2,
       force_update_check_only->6,
       no_check->3,
       normal->0,
       normal_check_only->4
   } OR {1,5,2,6,3,0,4}=0
                               FW Update Flags

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions