Skip to content

Commit 9f89098

Browse files
committed
Update: schema.
1 parent 10f2340 commit 9f89098

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

cmdcomp/v2/command/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ class V2SubcommandsCommand(Model):
139139
),
140140
]
141141

142-
subcommands: OrderedDict[SubcommandName, "V2Command"] = Field(
142+
raw_subcommands: OrderedDict[SubcommandName, "V2Command | None"] = Field(
143143
title="subcommands of the command.",
144+
alias="subcommands",
144145
default_factory=OrderedDict,
145146
)
146147

@@ -169,6 +170,20 @@ def keyword_arguments(self) -> OrderedDict[Keyword, V2Argument]:
169170
]
170171
)
171172

173+
@property
174+
def subcommands(self) -> OrderedDict[SubcommandName, "V2Command"]:
175+
return OrderedDict(
176+
[
177+
(
178+
name,
179+
V2SubcommandsCommand(alias=[], arguments=OrderedDict())
180+
if subcommand is None
181+
else subcommand,
182+
)
183+
for name, subcommand in self.raw_subcommands.items()
184+
]
185+
)
186+
172187
@property
173188
def subcommand_names_with_alias(self) -> list[SubcommandName]:
174189
return _subcommand_names_with_alias(self)

docs/config.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,9 @@
568568
},
569569
{
570570
"$ref": "#/$defs/V2SubcommandsCommand"
571+
},
572+
{
573+
"type": "null"
571574
}
572575
]
573576
},

0 commit comments

Comments
 (0)