@@ -491,17 +491,25 @@ extension HelpGenerationTests {
491491
492492 """ )
493493 }
494-
495- struct optionsToHide : ParsableArguments {
494+ }
495+
496+ extension HelpGenerationTests {
497+ private struct optionsToHide : ParsableArguments {
496498 @Flag ( help: " Verbose " )
497499 var verbose : Bool = false
498500
499501 @Option ( help: " Custom Name " )
500502 var customName : String ?
503+
504+ @Option ( help: . hidden)
505+ var hiddenOption : String ?
506+
507+ @Argument ( help: . private)
508+ var privateArg : String ?
501509 }
502510
503511 @available ( * , deprecated)
504- struct HideOptionGroupLegacyDriver : ParsableCommand {
512+ private struct HideOptionGroupLegacyDriver : ParsableCommand {
505513 static let configuration = CommandConfiguration ( commandName: " driver " , abstract: " Demo hiding option groups " )
506514
507515 @OptionGroup ( _hiddenFromHelp: true )
@@ -511,51 +519,72 @@ extension HelpGenerationTests {
511519 var timeout : Int ?
512520 }
513521
514- struct HideOptionGroupDriver : ParsableCommand {
522+ private struct HideOptionGroupDriver : ParsableCommand {
515523 static let configuration = CommandConfiguration ( commandName: " driver " , abstract: " Demo hiding option groups " )
516524
517- @OptionGroup ( _visibility : . hidden)
525+ @OptionGroup ( visibility : . hidden)
518526 var hideMe : optionsToHide
519527
520528 @Option ( help: " Time to wait before timeout (in seconds) " )
521529 var timeout : Int ?
522530 }
523531
524- @available ( * , deprecated)
525- func testHidingOptionGroup( ) throws {
526- let helpMessage = """
527- OVERVIEW: Demo hiding option groups
532+ private struct PrivateOptionGroupDriver : ParsableCommand {
533+ static let configuration = CommandConfiguration ( commandName: " driver " , abstract: " Demo hiding option groups " )
528534
529- USAGE: driver [--timeout <timeout>]
535+ @OptionGroup ( visibility: . private)
536+ var hideMe : optionsToHide
530537
531- OPTIONS:
532- -- timeout <timeout> Time to wait before timeout (in seconds)
533- -h, --help Show help information.
538+ @ Option ( help : " Time to wait before timeout (in seconds) " )
539+ var timeout : Int ?
540+ }
534541
535- """
536- AssertHelp ( . default, for: HideOptionGroupLegacyDriver . self, equals: helpMessage)
537- AssertHelp ( . default, for: HideOptionGroupDriver . self, equals: helpMessage)
542+ private var helpMessage : String { """
543+ OVERVIEW: Demo hiding option groups
544+
545+ USAGE: driver [--timeout <timeout>]
546+
547+ OPTIONS:
548+ --timeout <timeout> Time to wait before timeout (in seconds)
549+ -h, --help Show help information.
550+
551+ """
538552 }
539553
540- @ available ( * , deprecated )
541- func testHelpHiddenShowsAll ( ) throws {
542- let helpHiddenMessage = """
543- OVERVIEW: Demo hiding option groups
554+ private var helpHiddenMessage : String { """
555+ OVERVIEW: Demo hiding option groups
556+
557+ USAGE: driver [--verbose] [--custom-name <custom-name>] [--hidden-option <hidden- option>] [--timeout <timeout>]
544558
545- USAGE: driver [--verbose] [--custom-name <custom-name>] [--timeout <timeout>]
559+ OPTIONS:
560+ --verbose Verbose
561+ --custom-name <custom-name>
562+ Custom Name
563+ --hidden-option <hidden-option>
564+ --timeout <timeout> Time to wait before timeout (in seconds)
565+ -h, --help Show help information.
566+
567+ """
568+ }
546569
547- OPTIONS:
548- --verbose Verbose
549- --custom-name <custom-name>
550- Custom Name
551- --timeout <timeout> Time to wait before timeout (in seconds )
552- -h, --help Show help information.
570+ @ available ( * , deprecated )
571+ func testHidingOptionGroup ( ) throws {
572+ AssertHelp ( . default , for : HideOptionGroupLegacyDriver . self , equals : helpMessage )
573+ AssertHelp ( . default , for : HideOptionGroupDriver . self , equals : helpMessage )
574+ AssertHelp ( . default , for : PrivateOptionGroupDriver . self , equals : helpMessage )
575+ }
553576
554- """
577+ @available ( * , deprecated)
578+ func testHelpHiddenShowsDefaultAndHidden( ) throws {
555579 AssertHelp ( . hidden, for: HideOptionGroupLegacyDriver . self, equals: helpHiddenMessage)
556580 AssertHelp ( . hidden, for: HideOptionGroupDriver . self, equals: helpHiddenMessage)
581+
582+ // Note: Private option groups are not visible at `.hidden` help level.
583+ AssertHelp ( . hidden, for: PrivateOptionGroupDriver . self, equals: helpMessage)
557584 }
585+ }
558586
587+ extension HelpGenerationTests {
559588 struct AllValues : ParsableCommand {
560589 enum Manual : Int , ExpressibleByArgument {
561590 case foo
0 commit comments