Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Examples/repeat/Repeat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct Repeat: ParsableCommand {
var phrase: String

mutating func run() throws {
let repeatCount = count ?? .max
let repeatCount = count ?? 2

for i in 1...repeatCount {
if includeCounter {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct Repeat: ParsableCommand {
var phrase: String

mutating func run() throws {
let repeatCount = count ?? .max
let repeatCount = count ?? 2

for i in 1...repeatCount {
if includeCounter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct Repeat: ParsableCommand {
var count: Int?

mutating func run() throws {
let repeatCount = count ?? .max
let repeatCount = count ?? 2
for _ in 0..<repeatCount {
print(phrase)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct Repeat: ParsableCommand {
var count: Int?

mutating func run() throws {
for _ in 0..<(count ?? Int.max) {
for _ in 0..<(count ?? 2) {
print(phrase)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Repeat: ParsableCommand {
var count: Int?

mutating func run() throws {
let repeatCount = count ?? .max
let repeatCount = count ?? 2
for _ in 0..<repeatCount {
print(phrase)
}
Expand Down
14 changes: 14 additions & 0 deletions Tests/ArgumentParserExampleTests/RepeatExampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ import ArgumentParserTestHelpers

final class RepeatExampleTests: XCTestCase {
func testRepeat() throws {
try AssertExecuteCommand(command: "repeat hello", expected: """
hello
hello
""")
}

func testRepeat_include_counter() throws {
try AssertExecuteCommand(command: "repeat --include-counter hello", expected: """
1: hello
2: hello
""")
}

func testRepeat_Count() throws {
try AssertExecuteCommand(command: "repeat hello --count 6", expected: """
hello
hello
Expand Down