Skip to content

Commit 5ca178d

Browse files
committed
Update to swift-tools-version:5.5
Declare Deal command with @main attribute
1 parent 48c24a1 commit 5ca178d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.3
1+
// swift-tools-version:5.5
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
/*
@@ -30,7 +30,7 @@ let package = Package(
3030
targets: [
3131
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
3232
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
33-
.target(
33+
.executableTarget(
3434
name: "dealer",
3535
dependencies: [
3636
.product(name: "DeckOfPlayingCards",

Sources/dealer/main.swift renamed to Sources/dealer/Deal.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#if os(Linux)
1212
import Glibc
13-
srandom(UInt32(clock()))
1413
#endif
1514

1615
import Foundation
@@ -20,6 +19,7 @@ import ArgumentParser
2019
var stdout = FileHandle.standardOutput
2120
var stderr = FileHandle.standardError
2221

22+
@main
2323
struct Deal: ParsableCommand {
2424
static var configuration = CommandConfiguration(
2525
abstract: "Shuffles a deck of playing cards and deals a number of cards.",
@@ -32,6 +32,10 @@ struct Deal: ParsableCommand {
3232
var count: UInt = 10
3333

3434
mutating func run() throws {
35+
#if os(Linux)
36+
srandom(UInt32(clock()))
37+
#endif
38+
3539
var deck = Deck.standard52CardDeck()
3640
deck.shuffle()
3741

@@ -45,5 +49,3 @@ struct Deal: ParsableCommand {
4549
}
4650
}
4751
}
48-
49-
Deal.main()

0 commit comments

Comments
 (0)