Skip to content

When displaying default values do not display [] when value is null #2582

Open
@blowdart

Description

@blowdart

v2.0.0-beta5.25306.1

I have some default values that can be sourced from environment variables if they're present.

For example,

        var passwordOption = new Option<string?>("--password". "-p", "/p")
        {
            Description = "The password to use.",
            DefaultValueFactory = defaultValue =>
            {
                if (string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("_Password")))
                {
                    return null;
                }

                return Environment.GetEnvironmentVariable("_Password");
            }
        };

Currently the help text would display

-p, --password          The password to use. []

It would, to my mind, be cleaner if, when the DefaultValueFactory returns null that nothing is displayed as the default, because in this case there is no default.

e.g.

-p, --password          The password to use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions