You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/decorators.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,14 +86,17 @@ Instead, `@hubcommander_command` has an abstraction layer that can take care of
86
86
87
87
Here is an example of a multiple choice argument, as seen in the `!ListPRs` command:
88
88
```
89
-
dict(name="state", properties=dict(type=str, help="The state of the PR. Must be one of: `{values}`"),
89
+
dict(name="state", properties=dict(type=str.lower, help="The state of the PR. Must be one of: `{values}`"),
90
90
choices="permitted_states")
91
91
```
92
92
93
93
In here, `choices` refers to the name of the `plugin.commands[THECOMMANDHERE][AListOfAvailableChoices]`. It is the name
94
94
of the `list` within the plugin's command configuration that contains the available choices for the argument. This is done
95
95
because it allows the user of HubCommander to override this list in the plugin's configuration.
96
96
97
+
Also keep note of the `type`. The `type` in the example above is set to `str.lower`. This is to ensure that you
98
+
have case insensitivity in the parsed command. This is documented on StackOverflow [here](https://stackoverflow.com/questions/27616778/case-insensitive-argparse-choices/27616814).
99
+
97
100
Additionally, the `help` text is altered to include `{values}`. The `@hubcommander_command` decorator will properly format
98
101
the help text for that argument and fill in `{values}` with a comma separated list of the values in the specified list.
0 commit comments