@@ -4,10 +4,33 @@ import Foundation
4
4
import Result
5
5
import ReactiveSwift
6
6
import Curry
7
- import PrettyColors
8
7
9
8
/// Type that encapsulates the configuration and evaluation of the `outdated` subcommand.
10
9
public struct OutdatedCommand : CommandProtocol {
10
+ enum UpdateAvailabilityAndApplicability : String {
11
+ case updatesAvailableAllApplicable =
12
+ " Will be updated to the newest version. "
13
+ case updatesAvailableSomeApplicable =
14
+ " Will be updated, but not to the newest version because of the specified version in Cartfile. "
15
+ case updatesAvailableNoneApplicable =
16
+ " Will not be updated because of the specified version in Cartfile. "
17
+ case noUpdatesAvailable =
18
+ " Will not be updated: no updates available. "
19
+
20
+ init ( currentVersion current: PinnedVersion , applicableVersion applicable: PinnedVersion , latestVersion latest: PinnedVersion ) {
21
+ switch ( current, applicable, latest) {
22
+ case ( current, applicable, latest) where current != latest && applicable == latest:
23
+ self = . updatesAvailableAllApplicable
24
+ case ( current, applicable, latest) where current != applicable && applicable != latest:
25
+ self = . updatesAvailableSomeApplicable
26
+ case ( current, applicable, latest) where current != latest && current == applicable:
27
+ self = . updatesAvailableNoneApplicable
28
+ default :
29
+ self = . noUpdatesAvailable
30
+ }
31
+ }
32
+ }
33
+
11
34
public struct Options : OptionsProtocol {
12
35
public let useSSH : Bool
13
36
public let isVerbose : Bool
@@ -56,39 +79,17 @@ public struct OutdatedCommand: CommandProtocol {
56
79
if !outdatedDependencies. isEmpty {
57
80
carthage. println ( formatting. path ( " The following dependencies are outdated: " ) )
58
81
59
- for (project, current, updated, latest) in outdatedDependencies {
60
- let versionColor : Color . Named . Color
61
- switch ( current, updated, latest) {
62
- case ( _, updated, latest) where updated == latest:
63
- // Update available and applicable
64
- versionColor = . green
65
- case ( current, updated, latest) where current != updated && updated != latest:
66
- // Update availabe and applicable, but not to the latest version due to version lock
67
- versionColor = . yellow
68
- case ( current, updated, latest) where current == updated:
69
- // Update available, but not applicable due to version lock
70
- versionColor = . red
71
- default :
72
- versionColor = . white
73
- }
74
-
82
+ for (project, current, applicable, latest) in outdatedDependencies {
75
83
if options. outputXcodeWarnings {
76
- carthage. println ( " warning: \( formatting. projectName ( project. name) ) is out of date ( \( current) -> \( updated ) ) (Latest: \( latest) ) " )
84
+ carthage. println ( " warning: \( formatting. projectName ( project. name) ) is out of date ( \( current) -> \( applicable ) ) (Latest: \( latest) ) " )
77
85
} else {
78
- let versionSummary = formatting . colored ( current. description , color : versionColor )
79
- + " -> " + formatting. colored ( updated . description , color : versionColor )
80
- + " (Latest: \( latest) ) "
86
+ let availability = UpdateAvailabilityAndApplicability ( currentVersion : current, applicableVersion : applicable , latestVersion : latest )
87
+ let style = formatting [ availability ]
88
+ let versionSummary = " \( style ( current . description ) ) -> \( style ( applicable . description ) ) (Latest: \( latest) ) "
81
89
carthage. println ( formatting. projectName ( project. name) + " " + versionSummary)
82
90
}
83
91
}
84
-
85
- if options. colorOptions. formatting. isColorful {
86
- carthage. println ( formatting. path ( " The color indicates what happens when you run `carthage update` " ) )
87
- carthage. println ( formatting. colored ( " <green> " , color: . green) + " \t \t - Will be updated to the newest version " )
88
- carthage. println ( formatting. colored ( " <yellow> " , color: . yellow) + " \t - Will be updated, but not to the newest version "
89
- + " because of the specified version in Cartfile " )
90
- carthage. println ( formatting. colored ( " <red> " , color: . red) + " \t \t - Will not be updated because of the specified version in Cartfile " )
91
- }
92
+ formatting. legendForOutdatedCommand. map ( carthage. println)
92
93
} else {
93
94
carthage. println ( " All dependencies are up to date. " )
94
95
}
0 commit comments