Skip to content

Commit 27eaed6

Browse files
committed
Port code to Swift 5.
1 parent b6c7786 commit 27eaed6

28 files changed

+55
-46
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.3 (2019-03-30)
4+
- Migrated library to Xcode 10.2
5+
- Ported code to Swift 5
6+
37
## 0.2 (2018-06-10)
48
- Bug fixes
59
- Support of usage descriptions

Diff for: CommandLineKit.xcodeproj/project.pbxproj

+9-8
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,11 @@
284284
};
285285
CCFC2AD2207A636B00EDDADD = {
286286
CreatedOnToolsVersion = 9.3;
287-
LastSwiftMigration = 1000;
287+
LastSwiftMigration = 1020;
288288
};
289289
CCFC2AEB207A69B900EDDADD = {
290290
CreatedOnToolsVersion = 9.3;
291-
LastSwiftMigration = 1000;
291+
LastSwiftMigration = 1020;
292292
};
293293
};
294294
};
@@ -298,6 +298,7 @@
298298
hasScannedForEncodings = 0;
299299
knownRegions = (
300300
en,
301+
Base,
301302
);
302303
mainGroup = CC7A60DF207A62A5007376A0;
303304
productRefGroup = CC7A60E8207A62A5007376A0 /* Products */;
@@ -432,7 +433,7 @@
432433
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
433434
GCC_WARN_UNUSED_FUNCTION = YES;
434435
GCC_WARN_UNUSED_VARIABLE = YES;
435-
MACOSX_DEPLOYMENT_TARGET = 10.11;
436+
MACOSX_DEPLOYMENT_TARGET = 10.12;
436437
MTL_ENABLE_DEBUG_INFO = YES;
437438
ONLY_ACTIVE_ARCH = YES;
438439
SDKROOT = macosx;
@@ -479,7 +480,7 @@
479480
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
480481
GCC_WARN_UNUSED_FUNCTION = YES;
481482
GCC_WARN_UNUSED_VARIABLE = YES;
482-
MACOSX_DEPLOYMENT_TARGET = 10.11;
483+
MACOSX_DEPLOYMENT_TARGET = 10.12;
483484
MTL_ENABLE_DEBUG_INFO = NO;
484485
SDKROOT = macosx;
485486
SWIFT_COMPILATION_MODE = wholemodule;
@@ -565,7 +566,7 @@
565566
SKIP_INSTALL = YES;
566567
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
567568
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
568-
SWIFT_VERSION = 4.2;
569+
SWIFT_VERSION = 5.0;
569570
VERSIONING_SYSTEM = "apple-generic";
570571
VERSION_INFO_PREFIX = "";
571572
};
@@ -614,7 +615,7 @@
614615
SKIP_INSTALL = YES;
615616
SWIFT_COMPILATION_MODE = wholemodule;
616617
SWIFT_OPTIMIZATION_LEVEL = "-O";
617-
SWIFT_VERSION = 4.2;
618+
SWIFT_VERSION = 5.0;
618619
VERSIONING_SYSTEM = "apple-generic";
619620
VERSION_INFO_PREFIX = "";
620621
};
@@ -654,7 +655,7 @@
654655
PRODUCT_NAME = "$(TARGET_NAME)";
655656
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
656657
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
657-
SWIFT_VERSION = 4.2;
658+
SWIFT_VERSION = 5.0;
658659
};
659660
name = Debug;
660661
};
@@ -692,7 +693,7 @@
692693
PRODUCT_NAME = "$(TARGET_NAME)";
693694
SWIFT_COMPILATION_MODE = wholemodule;
694695
SWIFT_OPTIMIZATION_LEVEL = "-O";
695-
SWIFT_VERSION = 4.2;
696+
SWIFT_VERSION = 5.0;
696697
};
697698
name = Release;
698699
};

Diff for: Package.swift

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
// swift-tools-version:4.2
1+
// swift-tools-version:5.0
22
//
33
// Package.swift
44
// CommandLineKit
55
//
66
// Build targets by calling the Swift Package Manager in the following way for debug purposes:
7-
// swift build -Xswiftc "-target" -Xswiftc "x86_64-apple-macosx10.11"
7+
// swift build
88
//
99
// A release can be built with these options:
10-
// swift build -c release -Xswiftc -static-stdlib -Xswiftc "-target" -Xswiftc "x86_64-apple-macosx10.11"
10+
// swift build -c release
1111
//
1212
// Created by Matthias Zenger on 06/05/2017.
13-
// Copyright © 2018 Google LLC
13+
// Copyright © 2018-2019 Google LLC
1414
//
1515
// Redistribution and use in source and binary forms, with or without
1616
// modification, are permitted provided that the following conditions are met:
@@ -42,6 +42,9 @@ import PackageDescription
4242

4343
let package = Package(
4444
name: "CommandLineKit",
45+
platforms: [
46+
.macOS(.v10_12)
47+
],
4548
products: [
4649
.library(name: "CommandLineKit", targets: ["CommandLineKit"]),
4750
.executable(name: "CommandLineKitDemo", targets: ["CommandLineKitDemo"])
@@ -57,5 +60,5 @@ let package = Package(
5760
.testTarget(name: "CommandLineKitTests",
5861
dependencies: ["CommandLineKit"])
5962
],
60-
swiftLanguageVersions: [.v4_2]
63+
swiftLanguageVersions: [.v5]
6164
)

Diff for: README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[![Platform: macOS](https://img.shields.io/badge/Platform-macOS-blue.svg?style=flat)](https://developer.apple.com/osx/)
44
[![Platform: Linux](https://img.shields.io/badge/Platform-Linux-blue.svg?style=flat)](https://www.ubuntu.com/)
5-
[![Language: Swift 4.2](https://img.shields.io/badge/Language-Swift%204.2-green.svg?style=flat)](https://developer.apple.com/swift/)
6-
[![IDE: Xcode 10.0](https://img.shields.io/badge/IDE-Xcode%2010.0-orange.svg?style=flat)](https://developer.apple.com/xcode/)
5+
[![Language: Swift 5](https://img.shields.io/badge/Language-Swift%205-green.svg?style=flat)](https://developer.apple.com/swift/)
6+
[![IDE: Xcode 10.2](https://img.shields.io/badge/IDE-Xcode%2010.2-orange.svg?style=flat)](https://developer.apple.com/xcode/)
77
[![Carthage: compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
88
[![License: BSD](https://img.shields.io/badge/License-BSD-lightgrey.svg?style=flat)](https://developers.google.com/open-source/licenses/bsd)
99

@@ -197,7 +197,7 @@ if let ln = LineReader() {
197197

198198
## Requirements
199199

200-
- [Xcode 10.0](https://developer.apple.com/xcode/)
201-
- [Swift 4.2](https://developer.apple.com/swift/)
200+
- [Xcode 10.2](https://developer.apple.com/xcode/)
201+
- [Swift 5](https://developer.apple.com/swift/)
202202
- [Carthage](https://github.com/Carthage/Carthage)
203203
- [Swift Package Manager](https://swift.org/package-manager/)

Diff for: Sources/CommandLineKit/AnsiCodes.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 07/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
// Copyright © 2017 Andy Best <andybest.net at gmail dot com>
88
// Copyright © 2010-2014 Salvatore Sanfilippo <antirez at gmail dot com>
99
// Copyright © 2010-2013 Pieter Noordhuis <pcnoordhuis at gmail dot com>

Diff for: Sources/CommandLineKit/BackgroundColor.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 18/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:

Diff for: Sources/CommandLineKit/CommandLineKit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 08/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:

Diff for: Sources/CommandLineKit/ControlCharacters.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 07/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
// Copyright © 2017 Andy Best <andybest.net at gmail dot com>
88
// Copyright © 2010-2014, Salvatore Sanfilippo <antirez at gmail dot com>
99
// Copyright © 2010-2013, Pieter Noordhuis <pcnoordhuis at gmail dot com>

Diff for: Sources/CommandLineKit/ConvertibleFromString.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 26/03/2017.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:

Diff for: Sources/CommandLineKit/EditState.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 07/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
// Copyright © 2017 Andy Best <andybest.net at gmail dot com>
88
// Copyright © 2010-2014 Salvatore Sanfilippo <antirez at gmail dot com>
99
// Copyright © 2010-2013 Pieter Noordhuis <pcnoordhuis at gmail dot com>

Diff for: Sources/CommandLineKit/Flag.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 25/03/2017.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:

Diff for: Sources/CommandLineKit/FlagError.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 25/03/2017.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:

Diff for: Sources/CommandLineKit/Flags.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 25/03/2017.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:

Diff for: Sources/CommandLineKit/Info.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.2.2</string>
18+
<string>0.3</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSHumanReadableCopyright</key>
22-
<string>Copyright © 2018 Google LLC</string>
22+
<string>Copyright © 2018-2019 Google LLC</string>
2323
<key>NSPrincipalClass</key>
2424
<string></string>
2525
</dict>

Diff for: Sources/CommandLineKit/LineReader.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 07/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
// Copyright © 2017 Andy Best <andybest.net at gmail dot com>
88
// Copyright © 2010-2014 Salvatore Sanfilippo <antirez at gmail dot com>
99
// Copyright © 2010-2013 Pieter Noordhuis <pcnoordhuis at gmail dot com>

Diff for: Sources/CommandLineKit/LineReaderError.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 07/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
// Copyright © 2017 Andy Best <andybest.net at gmail dot com>
88
// Copyright © 2010-2014 Salvatore Sanfilippo <antirez at gmail dot com>
99
// Copyright © 2010-2013 Pieter Noordhuis <pcnoordhuis at gmail dot com>

Diff for: Sources/CommandLineKit/LineReaderHistory.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 07/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
// Copyright © 2017 Andy Best <andybest.net at gmail dot com>
88
// Copyright © 2010-2014 Salvatore Sanfilippo <antirez at gmail dot com>
99
// Copyright © 2010-2013 Pieter Noordhuis <pcnoordhuis at gmail dot com>

Diff for: Sources/CommandLineKit/Terminal.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 19/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
// Copyright © 2017 Andy Best <andybest.net at gmail dot com>
88
// Copyright © 2010-2014 Salvatore Sanfilippo <antirez at gmail dot com>
99
// Copyright © 2010-2013 Pieter Noordhuis <pcnoordhuis at gmail dot com>

Diff for: Sources/CommandLineKit/TextColor.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 07/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:

Diff for: Sources/CommandLineKit/TextProperties.swift

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 18/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:
@@ -170,10 +170,11 @@ public struct TextProperties: Hashable {
170170
backgroundColor: backgroundColor,
171171
textStyles: styles)
172172
}
173-
174-
public var hashValue: Int {
175-
return (((self.textColor?.hashValue ?? 0) &* 31) + self.textStyles.hashValue) &* 31 +
176-
(self.backgroundColor?.hashValue ?? 0)
173+
174+
public func hash(into hasher: inout Hasher) {
175+
hasher.combine(self.textColor)
176+
hasher.combine(self.textStyles)
177+
hasher.combine(self.backgroundColor)
177178
}
178179

179180
public static func == (lhs: TextProperties, rhs: TextProperties) -> Bool {

Diff for: Sources/CommandLineKit/TextStyle.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKit
44
//
55
// Created by Matthias Zenger on 18/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:

Diff for: Sources/CommandLineKitDemo/LinuxMain.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKitDemo
44
//
55
// Created by Matthias Zenger on 02/06/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:

Diff for: Sources/CommandLineKitDemo/main.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKitDemo
44
//
55
// Created by Matthias Zenger on 08/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:

Diff for: Tests/CommandLineKitTests/AnsiCodesTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKitTests
44
//
55
// Created by Matthias Zenger on 08/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
// Copyright © 2017 Andy Best <andybest.net at gmail dot com>
88
// Copyright © 2010-2014 Salvatore Sanfilippo <antirez at gmail dot com>
99
// Copyright © 2010-2013 Pieter Noordhuis <pcnoordhuis at gmail dot com>

Diff for: Tests/CommandLineKitTests/EditStateTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKitTests
44
//
55
// Created by Matthias Zenger on 08/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
// Copyright © 2017 Andy Best <andybest.net at gmail dot com>
88
// Copyright © 2010-2014 Salvatore Sanfilippo <antirez at gmail dot com>
99
// Copyright © 2010-2013 Pieter Noordhuis <pcnoordhuis at gmail dot com>

Diff for: Tests/CommandLineKitTests/FlagTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKitTests
44
//
55
// Created by Matthias Zenger on 25/03/2017.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:

Diff for: Tests/CommandLineKitTests/LineReaderHistoryTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKitTests
44
//
55
// Created by Matthias Zenger on 08/04/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
// Copyright © 2017 Andy Best <andybest.net at gmail dot com>
88
// Copyright © 2010-2014 Salvatore Sanfilippo <antirez at gmail dot com>
99
// Copyright © 2010-2013 Pieter Noordhuis <pcnoordhuis at gmail dot com>

Diff for: Tests/LinuxMain.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// CommandLineKitTests
44
//
55
// Created by Matthias Zenger on 02/06/2018.
6-
// Copyright © 2018 Google LLC
6+
// Copyright © 2018-2019 Google LLC
77
//
88
// Redistribution and use in source and binary forms, with or without
99
// modification, are permitted provided that the following conditions are met:

0 commit comments

Comments
 (0)