@@ -712,40 +712,42 @@ extension HelpGenerationTests {
712
712
713
713
extension HelpGenerationTests {
714
714
struct NonCustomUsage : ParsableCommand {
715
- static let configuration = CommandConfiguration ( )
715
+ struct ExampleSubcommand : ParsableCommand {
716
+ static let configuration = CommandConfiguration ( )
717
+ @Argument var output : String
718
+ }
719
+
720
+ static let configuration = CommandConfiguration (
721
+ subcommands: [ ExampleSubcommand . self] )
716
722
717
723
@Argument var file : String
718
724
@Flag var verboseMode = false
719
725
}
720
726
721
727
struct CustomUsageShort : ParsableCommand {
722
- static var configuration : CommandConfiguration {
723
- CommandConfiguration ( usage: """
728
+ static let configuration = CommandConfiguration (
729
+ usage: """
724
730
example [--verbose] <file-name>
725
731
""" )
726
- }
727
-
732
+
728
733
@Argument var file : String
729
734
@Flag var verboseMode = false
730
735
}
731
736
732
737
struct CustomUsageLong : ParsableCommand {
733
- static var configuration : CommandConfiguration {
734
- CommandConfiguration ( usage: """
738
+ static let configuration = CommandConfiguration (
739
+ usage: """
735
740
example <file-name>
736
741
example --verbose <file-name>
737
742
example --help
738
743
""" )
739
- }
740
-
744
+
741
745
@Argument var file : String
742
746
@Flag var verboseMode = false
743
747
}
744
748
745
749
struct CustomUsageHidden : ParsableCommand {
746
- static var configuration : CommandConfiguration {
747
- CommandConfiguration ( usage: " " )
748
- }
750
+ static let configuration = CommandConfiguration ( usage: " " )
749
751
750
752
@Argument var file : String
751
753
@Flag var verboseMode = false
@@ -755,14 +757,32 @@ extension HelpGenerationTests {
755
757
AssertEqualStrings (
756
758
actual: NonCustomUsage . helpMessage ( columns: 80 ) ,
757
759
expected: """
758
- USAGE: non-custom-usage <file> [--verbose-mode]
760
+ USAGE: non-custom-usage <file> [--verbose-mode] <subcommand>
759
761
760
762
ARGUMENTS:
761
763
<file>
762
764
763
765
OPTIONS:
764
766
--verbose-mode
765
767
-h, --help Show help information.
768
+
769
+ SUBCOMMANDS:
770
+ example-subcommand
771
+
772
+ See 'non-custom-usage help <subcommand>' for detailed help.
773
+ """ )
774
+
775
+ AssertEqualStrings (
776
+ actual: NonCustomUsage . helpMessage (
777
+ for: NonCustomUsage . ExampleSubcommand. self, columns: 80 ) ,
778
+ expected: """
779
+ USAGE: non-custom-usage example-subcommand <output>
780
+
781
+ ARGUMENTS:
782
+ <output>
783
+
784
+ OPTIONS:
785
+ -h, --help Show help information.
766
786
767
787
""" )
768
788
@@ -814,7 +834,7 @@ extension HelpGenerationTests {
814
834
actual: NonCustomUsage . fullMessage ( for: ValidationError ( " Test " ) ) ,
815
835
expected: """
816
836
Error: Test
817
- Usage: non-custom-usage <file> [--verbose-mode]
837
+ Usage: non-custom-usage <file> [--verbose-mode] <subcommand>
818
838
See 'non-custom-usage --help' for more information.
819
839
""" )
820
840
@@ -848,7 +868,14 @@ extension HelpGenerationTests {
848
868
AssertEqualStrings (
849
869
actual: NonCustomUsage . usageString ( ) ,
850
870
expected: """
851
- non-custom-usage <file> [--verbose-mode]
871
+ non-custom-usage <file> [--verbose-mode] <subcommand>
872
+ """ )
873
+
874
+ AssertEqualStrings (
875
+ actual: NonCustomUsage . usageString (
876
+ for: NonCustomUsage . ExampleSubcommand. self) ,
877
+ expected: """
878
+ non-custom-usage example-subcommand <output>
852
879
""" )
853
880
854
881
AssertEqualStrings (
0 commit comments