Skip to content

Commit

Permalink
Update: schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
yassun7010 committed Aug 3, 2023
1 parent 10f2340 commit 9f89098
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cmdcomp/v2/command/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ class V2SubcommandsCommand(Model):
),
]

subcommands: OrderedDict[SubcommandName, "V2Command"] = Field(
raw_subcommands: OrderedDict[SubcommandName, "V2Command | None"] = Field(
title="subcommands of the command.",
alias="subcommands",
default_factory=OrderedDict,
)

Expand Down Expand Up @@ -169,6 +170,20 @@ def keyword_arguments(self) -> OrderedDict[Keyword, V2Argument]:
]
)

@property
def subcommands(self) -> OrderedDict[SubcommandName, "V2Command"]:
return OrderedDict(
[
(
name,
V2SubcommandsCommand(alias=[], arguments=OrderedDict())
if subcommand is None
else subcommand,
)
for name, subcommand in self.raw_subcommands.items()
]
)

@property
def subcommand_names_with_alias(self) -> list[SubcommandName]:
return _subcommand_names_with_alias(self)
Expand Down
3 changes: 3 additions & 0 deletions docs/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@
},
{
"$ref": "#/$defs/V2SubcommandsCommand"
},
{
"type": "null"
}
]
},
Expand Down

0 comments on commit 9f89098

Please sign in to comment.