File tree Expand file tree Collapse file tree 6 files changed +19
-5
lines changed
Sources/ArgumentParser/Documentation.docc
Tests/ArgumentParserExampleTests Expand file tree Collapse file tree 6 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ struct Repeat: ParsableCommand {
2323 var phrase : String
2424
2525 mutating func run( ) throws {
26- let repeatCount = count ?? . max
26+ let repeatCount = count ?? 2
2727
2828 for i in 1 ... repeatCount {
2929 if includeCounter {
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ struct Repeat: ParsableCommand {
2323 var phrase: String
2424
2525 mutating func run () throws {
26- let repeatCount = count ?? . max
26+ let repeatCount = count ?? 2
2727
2828 for i in 1 ... repeatCount {
2929 if includeCounter {
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ struct Repeat: ParsableCommand {
2424 var count: Int ?
2525
2626 mutating func run () throws {
27- let repeatCount = count ?? . max
27+ let repeatCount = count ?? 2
2828 for _ in 0 ..< repeatCount {
2929 print (phrase)
3030 }
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ struct Repeat: ParsableCommand {
2525 var count: Int ?
2626
2727 mutating func run () throws {
28- for _ in 0 ..< (count ?? Int . max ) {
28+ for _ in 0 ..< (count ?? 2 ) {
2929 print (phrase)
3030 }
3131 }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ struct Repeat: ParsableCommand {
1212 var count: Int ?
1313
1414 mutating func run () throws {
15- let repeatCount = count ?? . max
15+ let repeatCount = count ?? 2
1616 for _ in 0 ..< repeatCount {
1717 print (phrase)
1818 }
Original file line number Diff line number Diff line change @@ -14,6 +14,20 @@ import ArgumentParserTestHelpers
1414
1515final class RepeatExampleTests : XCTestCase {
1616 func testRepeat( ) throws {
17+ try AssertExecuteCommand ( command: " repeat hello " , expected: """
18+ hello
19+ hello
20+ """ )
21+ }
22+
23+ func testRepeat_include_counter( ) throws {
24+ try AssertExecuteCommand ( command: " repeat --include-counter hello " , expected: """
25+ 1: hello
26+ 2: hello
27+ """ )
28+ }
29+
30+ func testRepeat_Count( ) throws {
1731 try AssertExecuteCommand ( command: " repeat hello --count 6 " , expected: """
1832 hello
1933 hello
You can’t perform that action at this time.
0 commit comments