Skip to content

Commit

Permalink
explicitly set option parameter name based on field name for cmd clas…
Browse files Browse the repository at this point in the history
…ses (#18926)
  • Loading branch information
altendky authored Dec 2, 2024
1 parent 61703ce commit 3bfb4da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions chia/_tests/cmds/test_cmd_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def cmd() -> None:
@chia_command(cmd, "temp_cmd", "blah", help="n/a")
class TempCMD:
some_option: int = option("-o", "--some-option", required=True, type=int)
choices: list[str] = option("--choice", multiple=True, type=str)

def run(self) -> None:
print(self.some_option)
Expand Down
1 change: 1 addition & 0 deletions chia/cmds/cmd_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def _generate_command_parser(cls: type[ChiaCommand]) -> _CommandParsingStage:
option_decorators.append(
click.option(
*option_args["param_decls"],
field_name,
type=type_arg,
**{k: v for k, v in option_args.items() if k not in {"param_decls", "type"}},
)
Expand Down

0 comments on commit 3bfb4da

Please sign in to comment.