@@ -22,6 +22,7 @@ type CommandSpec<'Inputs, 'Output> =
2222 Description: string
2323 Inputs: HandlerInput list
2424 Handler: 'Inputs -> 'Output
25+ Alias: string list
2526 SubCommands: System .CommandLine .Command list
2627 /// Registers extra inputs that can be parsed via the InvocationContext if more than 8 are required.
2728 ExtraInputs: HandlerInput list
@@ -30,6 +31,7 @@ type CommandSpec<'Inputs, 'Output> =
3031 {
3132 Description = " My Command"
3233 Inputs = []
34+ Alias = []
3335 ExtraInputs = []
3436 Handler = def< unit -> 'Output> // Support unit -> 'Output handler by default
3537 SubCommands = []
@@ -42,6 +44,7 @@ type BaseCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>() =
4244 {
4345 Description = spec.Description
4446 Inputs = spec.Inputs
47+ Alias = spec.Alias
4548 ExtraInputs = spec.ExtraInputs
4649 Handler = handler
4750 SubCommands = spec.SubCommands
@@ -120,6 +123,14 @@ type BaseCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>() =
120123 member this.AddCommands ( spec : CommandSpec < 'Inputs , 'Output >, subCommands : System.CommandLine.Command seq ) =
121124 { spec with SubCommands = spec.SubCommands @ ( subCommands |> Seq.toList) }
122125
126+ [<CustomOperation( " addAlias" ) >]
127+ member this.AddAlias ( spec : CommandSpec < 'Inputs , 'Output >, alias : string seq ) =
128+ { spec with Alias = spec.Alias @ ( alias |> Seq.toList) }
129+
130+ [<CustomOperation( " addAlias" ) >]
131+ member this.AddAlias ( spec : CommandSpec < 'Inputs , 'Output >, alias : string ) =
132+ { spec with Alias = alias :: spec.Alias }
133+
123134 /// Registers an additional input that can be manually parsed via the InvocationContext. (Use when more than 8 inputs are required.)
124135 [<CustomOperation( " add" ) >]
125136 member this.Add ( spec : CommandSpec < 'Inputs , 'Output >, extraInput : HandlerInput < 'Value >) =
@@ -152,6 +163,7 @@ type BaseCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>() =
152163 )
153164
154165 spec.SubCommands |> List.iter cmd.AddCommand
166+ spec.Alias |> List.iter cmd.AddAlias
155167 cmd
156168
157169 /// Sets a command handler that returns ` unit ` .
0 commit comments