Skip to content

Default argument for commands #227

@pkbehera

Description

@pkbehera
 root_menu->Insert(
        "show_updt",
        [&](ostream& out, uint32_t cnt = 1) {
            // do stuff
            //...
        },                                                                
        "Show next x updates");

I tried registering the above handler, expecting the command to use default argument of 1, when no arguments are provided. But it did not work, though it compiled just fine:

demo> help
Commands available:
 - help
        This help message
 - exit
        Quit the session
 - show_updt <unsigned int>
        Show next x updates
demo> show_updt 
wrong command: show_updt
demo> show_updt 2
demo> show_updt 1
demo>

Default arguments if available would be great!

Also, the error message here should better be something like missing command arguments instead of wrong command!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions