Modern Apps git

xtool.git

Public
git clone https://git.maproj.org/xtool.git
main ▾

xtool.git / Sources / XToolSupport / InstallCommand.swift

InstallCommand.swift47 lines · 1.3 KiBRaw
1import XUtils
2import Foundation
3import XKit
4import SwiftyMobileDevice
5import ArgumentParser
6
7struct InstallCommand: AsyncParsableCommand {
8 static let configuration = CommandConfiguration(
9 commandName: "install",
10 abstract: "Install an ipa file to your device"
11 )
12
13 @OptionGroup var connectionOptions: ConnectionOptions
14
15 @Argument(
16 help: "The path to a custom app/ipa to install"
17 ) var path: String
18
19 func run() async throws {
20 let token = try AuthToken.saved()
21
22 let client = try await connectionOptions.client()
23
24 d.out.print("Installing to device: \(client.deviceName) (udid: \(client.udid))")
25
26 let installDelegate = XToolInstallerDelegate()
27 let installer = IntegratedInstaller(
28 auth: token.authData(),
29 delegate: installDelegate
30 )
31
32 do {
33 try await installer.install(
34 app: URL(fileURLWithPath: path),
35 udid: client.udid,
36 lookupMode: .only(client.connectionType),
37 configureDevice: false,
38 )
39 d.out.print("\nSuccessfully installed!")
40 } catch let error as CancellationError {
41 throw error
42 } catch {
43 d.out.print("\nError: \(error)")
44 throw ExitCode.failure
45 }
46 }
47}