mirror of
https://github.com/mas-cli/mas
synced 2025-02-16 12:38:30 +00:00
Add a list-installed
command
This commit is contained in:
parent
dcef2608ab
commit
7b3b39ffc5
2 changed files with 23 additions and 1 deletions
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue