From 7828137a14befb5ce856bd9906ac832251c07cff Mon Sep 17 00:00:00 2001 From: Andrew Naylor Date: Sun, 20 Sep 2015 11:40:55 +0100 Subject: [PATCH] Add a Version command to the utility --- mas-cli.xcodeproj/project.pbxproj | 4 ++++ mas-cli/Commands/Version.swift | 25 +++++++++++++++++++++++++ mas-cli/main.swift | 1 + 3 files changed, 30 insertions(+) create mode 100644 mas-cli/Commands/Version.swift diff --git a/mas-cli.xcodeproj/project.pbxproj b/mas-cli.xcodeproj/project.pbxproj index c1ad49f..c7a8f21 100644 --- a/mas-cli.xcodeproj/project.pbxproj +++ b/mas-cli.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ ED0F238D1B8756E600AE40CD /* Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0F238C1B8756E600AE40CD /* Error.swift */; }; ED0F23901B87A56F00AE40CD /* ISStoreAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED0F238F1B87A56F00AE40CD /* ISStoreAccount.swift */; }; EDA3BE521B8B84AF00C18D70 /* SSPurchase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDA3BE511B8B84AF00C18D70 /* SSPurchase.swift */; }; + EDB6CE8C1BAEC3D400648B4D /* Version.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDB6CE8B1BAEC3D400648B4D /* Version.swift */; settings = {ASSET_TAGS = (); }; }; EDEAA0C01B51CE6200F2FC3F /* StoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDEAA0BF1B51CE6200F2FC3F /* StoreFoundation.framework */; }; EDEAA17D1B5C579100F2FC3F /* CommerceKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EDEAA17C1B5C579100F2FC3F /* CommerceKit.framework */; }; /* End PBXBuildFile section */ @@ -74,6 +75,7 @@ ED1EF9581BA6BBBF0075453C /* SSPurchaseResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSPurchaseResponse.h; sourceTree = ""; }; EDA3BE511B8B84AF00C18D70 /* SSPurchase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SSPurchase.swift; sourceTree = ""; }; EDB6CE8A1BAEB95100648B4D /* mas-cli-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "mas-cli-Info.plist"; sourceTree = ""; }; + EDB6CE8B1BAEC3D400648B4D /* Version.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Version.swift; sourceTree = ""; }; EDEAA0BF1B51CE6200F2FC3F /* StoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreFoundation.framework; path = /System/Library/PrivateFrameworks/StoreFoundation.framework; sourceTree = ""; }; EDEAA12C1B51CF8000F2FC3F /* mas-cli-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "mas-cli-Bridging-Header.h"; sourceTree = ""; }; EDEAA1311B5C576D00F2FC3F /* CKAccountStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CKAccountStore.h; sourceTree = ""; }; @@ -169,6 +171,7 @@ ED0F237E1B87522400AE40CD /* Install.swift */, ED0F23821B87533A00AE40CD /* List.swift */, ED0F23841B87536A00AE40CD /* Outdated.swift */, + EDB6CE8B1BAEC3D400648B4D /* Version.swift */, ); name = Commands; path = "mas-cli/Commands"; @@ -307,6 +310,7 @@ ED031A7C1B5127C00097692E /* main.swift in Sources */, 92828DCD99CED47F54242776 /* Option.swift in Sources */, ED0F23851B87536A00AE40CD /* Outdated.swift in Sources */, + EDB6CE8C1BAEC3D400648B4D /* Version.swift in Sources */, ED0F23891B87543D00AE40CD /* PurchaseDownloadObserver.swift in Sources */, 1CC607DA6B900AA3FEC3F6D8 /* Result.swift in Sources */, D40342B675C91E513F04B66E /* ResultType.swift in Sources */, diff --git a/mas-cli/Commands/Version.swift b/mas-cli/Commands/Version.swift new file mode 100644 index 0000000..4006967 --- /dev/null +++ b/mas-cli/Commands/Version.swift @@ -0,0 +1,25 @@ +// +// Version.swift +// mas-cli +// +// Created by Andrew Naylor on 20/09/2015. +// Copyright © 2015 Andrew Naylor. All rights reserved. +// + +struct VersionCommand: CommandType { + let verb = "version" + let function = "Display version information about the tool" + + func run(mode: CommandMode) -> Result<(), CommandantError> { + switch mode { + case .Arguments: + let plist = NSBundle.mainBundle().infoDictionary + if let versionString = plist?["CFBundleShortVersionString"] { + print(versionString) + } + default: + break + } + return .Success(()) + } +} diff --git a/mas-cli/main.swift b/mas-cli/main.swift index 1c1f788..1591631 100644 --- a/mas-cli/main.swift +++ b/mas-cli/main.swift @@ -20,6 +20,7 @@ registry.register(AccountCommand()) registry.register(InstallCommand()) registry.register(ListCommand()) registry.register(OutdatedCommand()) +registry.register(VersionCommand()) registry.register(helpCommand) registry.main(defaultVerb: helpCommand.verb) { error in