@@ -491,17 +491,25 @@ extension HelpGenerationTests {
491
491
492
492
""" )
493
493
}
494
-
495
- struct optionsToHide : ParsableArguments {
494
+ }
495
+
496
+ extension HelpGenerationTests {
497
+ private struct optionsToHide : ParsableArguments {
496
498
@Flag ( help: " Verbose " )
497
499
var verbose : Bool = false
498
500
499
501
@Option ( help: " Custom Name " )
500
502
var customName : String ?
503
+
504
+ @Option ( help: . hidden)
505
+ var hiddenOption : String ?
506
+
507
+ @Argument ( help: . private)
508
+ var privateArg : String ?
501
509
}
502
510
503
511
@available ( * , deprecated)
504
- struct HideOptionGroupLegacyDriver : ParsableCommand {
512
+ private struct HideOptionGroupLegacyDriver : ParsableCommand {
505
513
static let configuration = CommandConfiguration ( commandName: " driver " , abstract: " Demo hiding option groups " )
506
514
507
515
@OptionGroup ( _hiddenFromHelp: true )
@@ -511,51 +519,72 @@ extension HelpGenerationTests {
511
519
var timeout : Int ?
512
520
}
513
521
514
- struct HideOptionGroupDriver : ParsableCommand {
522
+ private struct HideOptionGroupDriver : ParsableCommand {
515
523
static let configuration = CommandConfiguration ( commandName: " driver " , abstract: " Demo hiding option groups " )
516
524
517
- @OptionGroup ( _visibility : . hidden)
525
+ @OptionGroup ( visibility : . hidden)
518
526
var hideMe : optionsToHide
519
527
520
528
@Option ( help: " Time to wait before timeout (in seconds) " )
521
529
var timeout : Int ?
522
530
}
523
531
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 " )
528
534
529
- USAGE: driver [--timeout <timeout>]
535
+ @OptionGroup ( visibility: . private)
536
+ var hideMe : optionsToHide
530
537
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
+ }
534
541
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
+ """
538
552
}
539
553
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>]
544
558
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
+ }
546
569
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
+ }
553
576
554
- """
577
+ @available ( * , deprecated)
578
+ func testHelpHiddenShowsDefaultAndHidden( ) throws {
555
579
AssertHelp ( . hidden, for: HideOptionGroupLegacyDriver . self, equals: helpHiddenMessage)
556
580
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)
557
584
}
585
+ }
558
586
587
+ extension HelpGenerationTests {
559
588
struct AllValues : ParsableCommand {
560
589
enum Manual : Int , ExpressibleByArgument {
561
590
case foo
0 commit comments