1
1
package co.touchlab.xcode.cli
2
2
3
- import co.touchlab.kermit.Logger
4
- import co.touchlab.xcode.cli.command.Install
5
3
import co.touchlab.xcode.cli.util.Console
6
4
7
5
object InstallationFacade {
8
- private val logger = Logger .withTag(" InstallationFacade" )
9
-
10
- fun installAll (xcodeInstallations : List <XcodeHelper .XcodeInstallation >, fixXcode15 : Boolean ) {
6
+ suspend fun installAll (xcodeInstallations : List <XcodeHelper .XcodeInstallation >, fixXcode15 : Boolean ) {
11
7
XcodeHelper .ensureXcodeNotRunning()
12
8
13
9
val bundledVersion = PluginManager .bundledVersion
14
- logger.v { " Bundled plugin version = $bundledVersion " }
10
+ Console .muted( " Bundled plugin version = $bundledVersion " )
15
11
val installedVersion = PluginManager .installedVersion
16
- logger.v { " Installed plugin version = ${installedVersion ? : " N/A" } " }
12
+ Console .muted( " Installed plugin version = ${installedVersion ? : " N/A" } " )
17
13
18
14
if (installedVersion != null ) {
19
15
val (confirmation, notification) = when {
20
16
bundledVersion > installedVersion -> {
21
- " Do you want to update from $installedVersion to $bundledVersion ? y/n: " to " Updating to $bundledVersion "
17
+ " Do you want to update from $installedVersion to $bundledVersion ?" to " Updating to $bundledVersion "
22
18
}
23
19
bundledVersion == installedVersion -> {
24
- " Do you want to reinstall version $installedVersion ? y/n: " to " Reinstalling $installedVersion "
20
+ " Do you want to reinstall version $installedVersion ?" to " Reinstalling $installedVersion "
25
21
}
26
22
bundledVersion < installedVersion -> {
27
- " Do you want to downgrade from $installedVersion to $bundledVersion ? y/n: " to " Downgrading to $bundledVersion "
23
+ " Do you want to downgrade from $installedVersion to $bundledVersion ?" to " Downgrading to $bundledVersion "
28
24
}
29
25
else -> error(" Unhandled comparison possibility!" )
30
26
}
@@ -33,11 +29,11 @@ object InstallationFacade {
33
29
return
34
30
}
35
31
36
- logger.v { " Installation confirmed." }
37
- logger.i { notification }
32
+ Console .muted( " Installation confirmed." )
33
+ Console .info( notification)
38
34
uninstallAll()
39
35
} else {
40
- logger.i { " Installing $bundledVersion ." }
36
+ Console .info( " Installing $bundledVersion ." )
41
37
}
42
38
43
39
PluginManager .install()
@@ -50,36 +46,36 @@ object InstallationFacade {
50
46
LLDBInitManager .install()
51
47
PluginManager .enable(bundledVersion, xcodeInstallations)
52
48
53
- logger.i { " Installation complete." }
49
+ Console .info( " Installation complete." )
54
50
}
55
51
56
- fun enable (xcodeInstallations : List <XcodeHelper .XcodeInstallation >) {
52
+ suspend fun enable (xcodeInstallations : List <XcodeHelper .XcodeInstallation >) {
57
53
XcodeHelper .ensureXcodeNotRunning()
58
54
59
55
val installedVersion = PluginManager .installedVersion ? : run {
60
- Console .echo (" Plugin not installed, nothing to enable." )
56
+ Console .warning (" Plugin not installed, nothing to enable." )
61
57
return
62
58
}
63
59
64
60
PluginManager .enable(installedVersion, xcodeInstallations)
65
61
66
- logger.i { " Plugin enabled." }
62
+ Console .info( " Plugin enabled." )
67
63
}
68
64
69
- fun disable (xcodeInstallations : List <XcodeHelper .XcodeInstallation >) {
65
+ suspend fun disable (xcodeInstallations : List <XcodeHelper .XcodeInstallation >) {
70
66
XcodeHelper .ensureXcodeNotRunning()
71
67
72
68
val installedVersion = PluginManager .installedVersion ? : run {
73
- Console .echo (" Plugin not installed, nothing to disable." )
69
+ Console .warning (" Plugin not installed, nothing to disable." )
74
70
return
75
71
}
76
72
77
73
PluginManager .disable(installedVersion, xcodeInstallations)
78
74
79
- logger.i { " Plugin disabled." }
75
+ Console .info( " Plugin disabled." )
80
76
}
81
77
82
- fun fixXcode15 (xcodeInstallations : List <XcodeHelper .XcodeInstallation >) {
78
+ suspend fun fixXcode15 (xcodeInstallations : List <XcodeHelper .XcodeInstallation >) {
83
79
XcodeHelper .ensureXcodeNotRunning()
84
80
85
81
val installedVersion = PluginManager .installedVersion
@@ -95,14 +91,14 @@ object InstallationFacade {
95
91
}
96
92
}
97
93
98
- logger.i { " Xcode 15 fix applied." }
94
+ Console .info( " Xcode 15 fix applied." )
99
95
}
100
96
101
- fun sync (xcodeInstallations : List <XcodeHelper .XcodeInstallation >, fixXcode15 : Boolean ) {
97
+ suspend fun sync (xcodeInstallations : List <XcodeHelper .XcodeInstallation >, fixXcode15 : Boolean ) {
102
98
XcodeHelper .ensureXcodeNotRunning()
103
99
104
100
val installedVersion = PluginManager .installedVersion ? : run {
105
- Console .echo (" Plugin not installed, nothing to synchronize." )
101
+ Console .warning (" Plugin not installed, nothing to synchronize." )
106
102
return
107
103
}
108
104
@@ -113,16 +109,16 @@ object InstallationFacade {
113
109
}
114
110
PluginManager .enable(installedVersion, xcodeInstallations)
115
111
116
- logger.i { " Synchronization complete." }
112
+ Console .info( " Synchronization complete." )
117
113
}
118
114
119
- fun uninstallAll () {
120
- logger.v { " Will uninstall all plugin components." }
115
+ suspend fun uninstallAll () {
116
+ Console .muted( " Will uninstall all plugin components." )
121
117
XcodeHelper .ensureXcodeNotRunning()
122
118
PluginManager .uninstall()
123
119
LangSpecManager .uninstall()
124
120
LLDBInitManager .uninstall()
125
121
126
- logger.i { " Uninstallation complete." }
122
+ Console .info( " Uninstallation complete." )
127
123
}
128
124
}
0 commit comments