Skip to content

Display possible value for enum in Help text #92

@jerriep

Description

@jerriep

I have several options for my command which are limited to enumerated types. Currently, the help text is displayed as follows:

Usage: ghi list [options]

Options:
  -?|-h|--help            Show help information
  -a|--all                All
  -r|--repo <REPOSITORY>  The repository to limit the issues to
  -u|--user <USER>        The user who the issues are related to
  -R|--rel <RELATION>     The relation of the issues to the user
  -s|--state <STATE>      The state of the issues
  -t|--token <TOKEN>      Your GitHub Personal Access token

But I want to display the possible values for the enumerated types. What I have done (for now) is to update the rel option, for example, as follows:

[Option(CommandOptionType.SingleValue, Description = "The relation of the issues to the user", ShortName = "R", LongName = "rel",
    ValueName = "Assigned|Created|Mentioned")]
public IssueRelation Relation { get; set; } = IssueRelation.Assigned;

This will then display the possible values as follows:

Usage: ghi list [options]

Options:
  -?|-h|--help                           Show help information
  -a|--all                               All
  -r|--repo <REPOSITORY>                 The repository to limit the issues to
  -u|--user <USER>                       The user who the issues are related to
  -R|--rel <Assigned|Created|Mentioned>  The relation of the issues to the user
  -s|--state <STATE>                     The state of the issues
  -t|--token <TOKEN>                     Your GitHub Personal Access token

Is this the correct way to go about it? Or is there a way to automatically display the list of values in the case of enumerated types which I have missed?

Also, is this not perhaps something we can add as a standard "feature" to the generated help text? I think it is pretty common for certain options to be limited to specific predefined values.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions