Add a list-installed command

This commit is contained in:
Andrew Naylor 2015-08-02 22:42:01 +01:00
parent dcef2608ab
commit 7b3b39ffc5
2 changed files with 23 additions and 1 deletions

View file

@ -24,7 +24,7 @@
- (BOOL)isTrialVersionOfBundleIdentifier:(id)arg1;
- (id)receiptFromBundleAtPath:(id)arg1;
- (id)productForPath:(id)arg1;
- (id)allProducts;
- (NSArray<CKSoftwareProduct *>*)allProducts;
- (CKSoftwareProduct *)productForItemIdentifier:(unsigned long long)arg1;
- (CKSoftwareProduct *)productForBundleIdentifier:(NSString *)arg1;
- (void)removeProductsObserver:(id)arg1;

View file

@ -126,6 +126,27 @@ struct ListUpdatesCommand: CommandType {
}
}
struct ListInstalledCommand: CommandType {
let verb = "list-installed"
let function = "Lists apps from the Mac App Store which are currently installed"
func run(mode: CommandMode) -> Result<(), CommandantError<MASError>> {
switch mode {
case .Arguments:
let softwareMap = CKSoftwareMap.sharedSoftwareMap()
let products = softwareMap.allProducts()
products.map({ product -> Bool in
print(String(product.itemIdentifier) + " " + product.appName)
return true
})
default:
break
}
return .Success(())
}
}
public enum MASError: ErrorType, Equatable {
public var description: String {
return ""
@ -140,6 +161,7 @@ let registry = CommandRegistry<MASError>()
let helpCommand = HelpCommand(registry: registry)
registry.register(AccountCommand())
registry.register(InstallCommand())
registry.register(ListInstalledCommand())
registry.register(ListUpdatesCommand())
registry.register(helpCommand)