Skip to content

Updating 'Usage' key in formatter label not updating the output when running with --help #1249

@rafarrel

Description

@rafarrel

VERSION: 2.6.1
OS: Windows 11

Adding this line isn't updating the usage line to display USAGE: app_name.exe [OPTIONS] when I run my application with --help:

app.get_formatter()->label("Usage", "USAGE:");

It continues to just output the app name like this: app_name [OPTIONS]. However, doing this works:

class UsageFormatter final : public CLI::Formatter
{
public:
    std::string make_usage(const CLI::App* app, const std::string name) const override
    {
       return "USAGE: " + name + (app->get_help_ptr() != nullptr ? " [OPTIONS]" : "") + "\n";
    }
};

CLI::App app{};
app.formatter(std::make_shared<UsageFormatter>());

Is this a bug/am I doing something wrong? Or was this functionality removed?

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