@@ -37,6 +37,7 @@ type CommandSpec<'Inputs, 'Output> =
3737 SubCommands: System .CommandLine .Command list
3838 /// Registers extra inputs that can be parsed via the InvocationContext if more than 8 are required.
3939 ExtraInputs: ActionInput list
40+ Hidden: bool
4041 }
4142 static member Default =
4243 {
@@ -47,6 +48,7 @@ type CommandSpec<'Inputs, 'Output> =
4748 ExtraInputs = []
4849 Handler = def< unit -> 'Output> // Support unit -> 'Output handler by default
4950 SubCommands = []
51+ Hidden = false
5052 }
5153
5254/// Contains shared operations for building a `rootCommand`, `command` or `commandLineConfiguration` CE.
@@ -61,6 +63,7 @@ type BaseCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>() =
6163 ExtraInputs = spec.ExtraInputs
6264 Handler = handler
6365 SubCommands = spec.SubCommands
66+ Hidden = spec.Hidden
6467 }
6568
6669 /// Converts up to 8 handler inputs into a tuple of the specified action input type.
@@ -275,6 +278,7 @@ type BaseCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>() =
275278 )
276279 spec.SubCommands |> List.iter cmd.Add
277280 spec.Aliases |> List.iter cmd.Aliases.Add
281+ cmd.Hidden <- spec.Hidden
278282 cmd
279283
280284 /// Sets a command handler that returns `unit`.
@@ -433,6 +437,11 @@ type RootCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>(args: string ar
433437type CommandBuilder < 'A , 'B , 'C , 'D , 'E , 'F , 'G , 'H , 'Output >( name : string ) =
434438 inherit BaseCommandBuilder< 'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>()
435439
440+ /// Hides the command from the help output.
441+ [<CustomOperation( " hidden" ) >]
442+ member this.Hidden ( spec : CommandSpec < 'Inputs , 'Output >) =
443+ { spec with Hidden = true }
444+
436445 /// Returns a Command with a handler that returns unit.
437446 member this.Run ( spec : CommandSpec < 'Inputs , unit >) =
438447 Command( name)
0 commit comments