@@ -16,13 +16,18 @@ func downloadCmd() *cobra.Command {
16
16
var (
17
17
acquireLicense bool
18
18
outputPath string
19
+ appID int64
19
20
bundleID string
20
21
)
21
22
22
23
cmd := & cobra.Command {
23
24
Use : "download" ,
24
25
Short : "Download (encrypted) iOS app packages from the App Store" ,
25
26
RunE : func (cmd * cobra.Command , args []string ) error {
27
+ if appID == 0 && bundleID == "" {
28
+ return errors .New ("either the app ID or the bundle identifier must be specified" )
29
+ }
30
+
26
31
var lastErr error
27
32
var acc appstore.Account
28
33
@@ -43,13 +48,18 @@ func downloadCmd() *cobra.Command {
43
48
acc = loginResult .Account
44
49
}
45
50
46
- lookupResult , err := dependencies .AppStore .Lookup (appstore.LookupInput {Account : acc , BundleID : bundleID })
47
- if err != nil {
48
- return err
51
+ app := appstore.App {ID : appID }
52
+ if bundleID != "" {
53
+ lookupResult , err := dependencies .AppStore .Lookup (appstore.LookupInput {Account : acc , BundleID : bundleID })
54
+ if err != nil {
55
+ return err
56
+ }
57
+
58
+ app = lookupResult .App
49
59
}
50
60
51
61
if errors .Is (lastErr , appstore .ErrLicenseRequired ) {
52
- err := dependencies .AppStore .Purchase (appstore.PurchaseInput {Account : acc , App : lookupResult . App })
62
+ err := dependencies .AppStore .Purchase (appstore.PurchaseInput {Account : acc , App : app })
53
63
if err != nil {
54
64
return err
55
65
}
@@ -74,7 +84,7 @@ func downloadCmd() *cobra.Command {
74
84
)
75
85
}
76
86
77
- out , err := dependencies .AppStore .Download (appstore.DownloadInput {Account : acc , App : lookupResult . App , OutputPath : outputPath , Progress : progress })
87
+ out , err := dependencies .AppStore .Download (appstore.DownloadInput {Account : acc , App : app , OutputPath : outputPath , Progress : progress })
78
88
if err != nil {
79
89
return err
80
90
}
@@ -112,10 +122,10 @@ func downloadCmd() *cobra.Command {
112
122
},
113
123
}
114
124
115
- cmd .Flags ().StringVarP (& bundleID , "bundle-identifier" , "b" , "" , "The bundle identifier of the target iOS app (required)" )
125
+ cmd .Flags ().Int64VarP (& appID , "app-id" , "i" , 0 , "ID of the target iOS app (required)" )
126
+ cmd .Flags ().StringVarP (& bundleID , "bundle-identifier" , "b" , "" , "The bundle identifier of the target iOS app (overrides the app ID)" )
116
127
cmd .Flags ().StringVarP (& outputPath , "output" , "o" , "" , "The destination path of the downloaded app package" )
117
128
cmd .Flags ().BoolVar (& acquireLicense , "purchase" , false , "Obtain a license for the app if needed" )
118
- _ = cmd .MarkFlagRequired ("bundle-identifier" )
119
129
120
130
return cmd
121
131
}
0 commit comments