@@ -151,6 +151,18 @@ export class CommandRegistry {
151
151
this . _commandChanged . emit ( { id, type : id ? 'changed' : 'many-changed' } ) ;
152
152
}
153
153
154
+ /**
155
+ * Get the description for a specific command.
156
+ *
157
+ * @param id - The id of the command of interest.
158
+ *
159
+ * @returns The description for the command.
160
+ */
161
+ describedBy ( id : string ) : { args : ReadonlyJSONObject | null } {
162
+ let cmd = this . _commands [ id ] ;
163
+ return cmd ?. describedBy ?? { args : null } ;
164
+ }
165
+
154
166
/**
155
167
* Get the display label for a specific command.
156
168
*
@@ -685,6 +697,15 @@ export namespace CommandRegistry {
685
697
*/
686
698
execute : CommandFunc < any | Promise < any > > ;
687
699
700
+ /**
701
+ * JSON Schemas describing the command.
702
+ *
703
+ * #### Notes
704
+ * For now, the command arguments are the only one that can be
705
+ * described.
706
+ */
707
+ describedBy ?: { args ?: ReadonlyJSONObject } ;
708
+
688
709
/**
689
710
* The label for the command.
690
711
*
@@ -1242,6 +1263,7 @@ namespace Private {
1242
1263
*/
1243
1264
export interface ICommand {
1244
1265
readonly execute : CommandFunc < any > ;
1266
+ readonly describedBy : { args : ReadonlyJSONObject | null } ;
1245
1267
readonly label : CommandFunc < string > ;
1246
1268
readonly mnemonic : CommandFunc < number > ;
1247
1269
readonly icon : CommandFunc < VirtualElement . IRenderer | undefined > ;
@@ -1265,6 +1287,7 @@ namespace Private {
1265
1287
) : ICommand {
1266
1288
return {
1267
1289
execute : options . execute ,
1290
+ describedBy : { args : null , ...options . describedBy } ,
1268
1291
label : asFunc ( options . label , emptyStringFunc ) ,
1269
1292
mnemonic : asFunc ( options . mnemonic , negativeOneFunc ) ,
1270
1293
icon : asFunc ( options . icon , undefinedFunc ) ,
0 commit comments