11package co.touchlab.xcode.cli
22
3- import co.touchlab.kermit.Logger
4- import co.touchlab.xcode.cli.command.Install
53import co.touchlab.xcode.cli.util.Console
64
75object 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 ) {
117 XcodeHelper .ensureXcodeNotRunning()
128
139 val bundledVersion = PluginManager .bundledVersion
14- logger.v { " Bundled plugin version = $bundledVersion " }
10+ Console .muted( " Bundled plugin version = $bundledVersion " )
1511 val installedVersion = PluginManager .installedVersion
16- logger.v { " Installed plugin version = ${installedVersion ? : " N/A" } " }
12+ Console .muted( " Installed plugin version = ${installedVersion ? : " N/A" } " )
1713
1814 if (installedVersion != null ) {
1915 val (confirmation, notification) = when {
2016 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 "
2218 }
2319 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 "
2521 }
2622 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 "
2824 }
2925 else -> error(" Unhandled comparison possibility!" )
3026 }
@@ -33,11 +29,11 @@ object InstallationFacade {
3329 return
3430 }
3531
36- logger.v { " Installation confirmed." }
37- logger.i { notification }
32+ Console .muted( " Installation confirmed." )
33+ Console .info( notification)
3834 uninstallAll()
3935 } else {
40- logger.i { " Installing $bundledVersion ." }
36+ Console .info( " Installing $bundledVersion ." )
4137 }
4238
4339 PluginManager .install()
@@ -50,36 +46,36 @@ object InstallationFacade {
5046 LLDBInitManager .install()
5147 PluginManager .enable(bundledVersion, xcodeInstallations)
5248
53- logger.i { " Installation complete." }
49+ Console .info( " Installation complete." )
5450 }
5551
56- fun enable (xcodeInstallations : List <XcodeHelper .XcodeInstallation >) {
52+ suspend fun enable (xcodeInstallations : List <XcodeHelper .XcodeInstallation >) {
5753 XcodeHelper .ensureXcodeNotRunning()
5854
5955 val installedVersion = PluginManager .installedVersion ? : run {
60- Console .echo (" Plugin not installed, nothing to enable." )
56+ Console .warning (" Plugin not installed, nothing to enable." )
6157 return
6258 }
6359
6460 PluginManager .enable(installedVersion, xcodeInstallations)
6561
66- logger.i { " Plugin enabled." }
62+ Console .info( " Plugin enabled." )
6763 }
6864
69- fun disable (xcodeInstallations : List <XcodeHelper .XcodeInstallation >) {
65+ suspend fun disable (xcodeInstallations : List <XcodeHelper .XcodeInstallation >) {
7066 XcodeHelper .ensureXcodeNotRunning()
7167
7268 val installedVersion = PluginManager .installedVersion ? : run {
73- Console .echo (" Plugin not installed, nothing to disable." )
69+ Console .warning (" Plugin not installed, nothing to disable." )
7470 return
7571 }
7672
7773 PluginManager .disable(installedVersion, xcodeInstallations)
7874
79- logger.i { " Plugin disabled." }
75+ Console .info( " Plugin disabled." )
8076 }
8177
82- fun fixXcode15 (xcodeInstallations : List <XcodeHelper .XcodeInstallation >) {
78+ suspend fun fixXcode15 (xcodeInstallations : List <XcodeHelper .XcodeInstallation >) {
8379 XcodeHelper .ensureXcodeNotRunning()
8480
8581 val installedVersion = PluginManager .installedVersion
@@ -95,14 +91,14 @@ object InstallationFacade {
9591 }
9692 }
9793
98- logger.i { " Xcode 15 fix applied." }
94+ Console .info( " Xcode 15 fix applied." )
9995 }
10096
101- fun sync (xcodeInstallations : List <XcodeHelper .XcodeInstallation >, fixXcode15 : Boolean ) {
97+ suspend fun sync (xcodeInstallations : List <XcodeHelper .XcodeInstallation >, fixXcode15 : Boolean ) {
10298 XcodeHelper .ensureXcodeNotRunning()
10399
104100 val installedVersion = PluginManager .installedVersion ? : run {
105- Console .echo (" Plugin not installed, nothing to synchronize." )
101+ Console .warning (" Plugin not installed, nothing to synchronize." )
106102 return
107103 }
108104
@@ -113,16 +109,16 @@ object InstallationFacade {
113109 }
114110 PluginManager .enable(installedVersion, xcodeInstallations)
115111
116- logger.i { " Synchronization complete." }
112+ Console .info( " Synchronization complete." )
117113 }
118114
119- fun uninstallAll () {
120- logger.v { " Will uninstall all plugin components." }
115+ suspend fun uninstallAll () {
116+ Console .muted( " Will uninstall all plugin components." )
121117 XcodeHelper .ensureXcodeNotRunning()
122118 PluginManager .uninstall()
123119 LangSpecManager .uninstall()
124120 LLDBInitManager .uninstall()
125121
126- logger.i { " Uninstallation complete." }
122+ Console .info( " Uninstallation complete." )
127123 }
128124}
0 commit comments