From 5895b7b9174149a1cd6188852a36552b0f7f0255 Mon Sep 17 00:00:00 2001 From: CatalinaTest Date: Mon, 17 Aug 2020 10:05:43 -0700 Subject: [PATCH 01/12] functionality in place, signing error prevents use --- .../contents.xcworkspacedata | 3 + .../project.pbxproj | 330 ++++++++++++++++++ .../xcschemes/MorphicManualTesterCLI.xcscheme | 84 +++++ .../RegistryManager.swift | 126 +++++++ .../MorphicManualTesterCLI/main.swift | 151 ++++++++ 5 files changed, 694 insertions(+) create mode 100644 MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/project.pbxproj create mode 100644 MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/xcshareddata/xcschemes/MorphicManualTesterCLI.xcscheme create mode 100644 MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift create mode 100644 MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift diff --git a/MorphicLite.xcworkspace/contents.xcworkspacedata b/MorphicLite.xcworkspace/contents.xcworkspacedata index 14b971e6..622d3ca1 100644 --- a/MorphicLite.xcworkspace/contents.xcworkspacedata +++ b/MorphicLite.xcworkspace/contents.xcworkspacedata @@ -16,4 +16,7 @@ + + diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/project.pbxproj b/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/project.pbxproj new file mode 100644 index 00000000..87c244ef --- /dev/null +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/project.pbxproj @@ -0,0 +1,330 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + FFF243D824E7FA660054E3F4 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFF243D724E7FA660054E3F4 /* main.swift */; }; + FFF243DF24E807E50054E3F4 /* RegistryManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFF243DE24E807E50054E3F4 /* RegistryManager.swift */; }; + FFF243E824E99BA40054E3F4 /* MorphicCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FFF243E124E808EA0054E3F4 /* MorphicCore.framework */; }; + FFF243E924E99BA40054E3F4 /* MorphicCore.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FFF243E124E808EA0054E3F4 /* MorphicCore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + FFF243EB24E99BA60054E3F4 /* MorphicSettings.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FFF243E524E808ED0054E3F4 /* MorphicSettings.framework */; settings = {ATTRIBUTES = (Required, ); }; }; + FFF243EC24E99BA60054E3F4 /* MorphicSettings.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FFF243E524E808ED0054E3F4 /* MorphicSettings.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + FFF243D224E7FA660054E3F4 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + FFF243EA24E99BA50054E3F4 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + FFF243EC24E99BA60054E3F4 /* MorphicSettings.framework in Embed Frameworks */, + FFF243E924E99BA40054E3F4 /* MorphicCore.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + FFF243D424E7FA660054E3F4 /* morphictest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = morphictest; sourceTree = BUILT_PRODUCTS_DIR; }; + FFF243D724E7FA660054E3F4 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + FFF243DE24E807E50054E3F4 /* RegistryManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegistryManager.swift; sourceTree = ""; }; + FFF243E124E808EA0054E3F4 /* MorphicCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MorphicCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + FFF243E524E808ED0054E3F4 /* MorphicSettings.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MorphicSettings.framework; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + FFF243D124E7FA660054E3F4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + FFF243EB24E99BA60054E3F4 /* MorphicSettings.framework in Frameworks */, + FFF243E824E99BA40054E3F4 /* MorphicCore.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + FFF243CB24E7FA660054E3F4 = { + isa = PBXGroup; + children = ( + FFF243D624E7FA660054E3F4 /* MorphicManualTesterCLI */, + FFF243D524E7FA660054E3F4 /* Products */, + FFF243E024E808EA0054E3F4 /* Frameworks */, + ); + sourceTree = ""; + }; + FFF243D524E7FA660054E3F4 /* Products */ = { + isa = PBXGroup; + children = ( + FFF243D424E7FA660054E3F4 /* morphictest */, + ); + name = Products; + sourceTree = ""; + }; + FFF243D624E7FA660054E3F4 /* MorphicManualTesterCLI */ = { + isa = PBXGroup; + children = ( + FFF243D724E7FA660054E3F4 /* main.swift */, + FFF243DE24E807E50054E3F4 /* RegistryManager.swift */, + ); + path = MorphicManualTesterCLI; + sourceTree = ""; + }; + FFF243E024E808EA0054E3F4 /* Frameworks */ = { + isa = PBXGroup; + children = ( + FFF243E524E808ED0054E3F4 /* MorphicSettings.framework */, + FFF243E124E808EA0054E3F4 /* MorphicCore.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + FFF243D324E7FA660054E3F4 /* morphictest */ = { + isa = PBXNativeTarget; + buildConfigurationList = FFF243DB24E7FA660054E3F4 /* Build configuration list for PBXNativeTarget "morphictest" */; + buildPhases = ( + FFF243D024E7FA660054E3F4 /* Sources */, + FFF243D124E7FA660054E3F4 /* Frameworks */, + FFF243D224E7FA660054E3F4 /* CopyFiles */, + FFF243EA24E99BA50054E3F4 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = morphictest; + productName = MorphicManualTesterCLI; + productReference = FFF243D424E7FA660054E3F4 /* morphictest */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + FFF243CC24E7FA660054E3F4 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1160; + LastUpgradeCheck = 1160; + ORGANIZATIONNAME = "Raising the Floor"; + TargetAttributes = { + FFF243D324E7FA660054E3F4 = { + CreatedOnToolsVersion = 11.6; + }; + }; + }; + buildConfigurationList = FFF243CF24E7FA660054E3F4 /* Build configuration list for PBXProject "MorphicManualTesterCLI" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = FFF243CB24E7FA660054E3F4; + productRefGroup = FFF243D524E7FA660054E3F4 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + FFF243D324E7FA660054E3F4 /* morphictest */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + FFF243D024E7FA660054E3F4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + FFF243DF24E807E50054E3F4 /* RegistryManager.swift in Sources */, + FFF243D824E7FA660054E3F4 /* main.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + FFF243D924E7FA660054E3F4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = ""; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + FFF243DA24E7FA660054E3F4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + PRODUCT_NAME = ""; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + FFF243DC24E7FA660054E3F4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = 5AAXYGZ428; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + FFF243DD24E7FA660054E3F4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = 5AAXYGZ428; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + FFF243CF24E7FA660054E3F4 /* Build configuration list for PBXProject "MorphicManualTesterCLI" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + FFF243D924E7FA660054E3F4 /* Debug */, + FFF243DA24E7FA660054E3F4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + FFF243DB24E7FA660054E3F4 /* Build configuration list for PBXNativeTarget "morphictest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + FFF243DC24E7FA660054E3F4 /* Debug */, + FFF243DD24E7FA660054E3F4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = FFF243CC24E7FA660054E3F4 /* Project object */; +} diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/xcshareddata/xcschemes/MorphicManualTesterCLI.xcscheme b/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/xcshareddata/xcschemes/MorphicManualTesterCLI.xcscheme new file mode 100644 index 00000000..22925f2b --- /dev/null +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/xcshareddata/xcschemes/MorphicManualTesterCLI.xcscheme @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift new file mode 100644 index 00000000..b327c24d --- /dev/null +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift @@ -0,0 +1,126 @@ +// Copyright 2020 Raising the Floor - International +// +// Licensed under the New BSD license. You may not use this file except in +// compliance with this License. +// +// You may obtain a copy of the License at +// https://github.com/GPII/universal/blob/master/LICENSE.txt +// +// The R&D leading to these results received funding from the: +// * Rehabilitation Services Administration, US Dept. of Education under +// grant H421A150006 (APCP) +// * National Institute on Disability, Independent Living, and +// Rehabilitation Research (NIDILRR) +// * Administration for Independent Living & Dept. of Education under grants +// H133E080022 (RERC-IT) and H133E130028/90RE5003-01-00 (UIITA-RERC) +// * European Union's Seventh Framework Programme (FP7/2007-2013) grant +// agreement nos. 289016 (Cloud4all) and 610510 (Prosperity4All) +// * William and Flora Hewlett Foundation +// * Ontario Ministry of Research and Innovation +// * Canadian Foundation for Innovation +// * Adobe Foundation +// * Consumer Electronics Association Foundation + +import MorphicCore +import MorphicSettings + +public class RegistryManager +{ + public func load(registry: String) -> Bool + { + let filepath = URL(fileURLWithPath: registry) + SettingsManager.shared.populateSolutions(from: filepath) + return !SettingsManager.shared.solutions.isEmpty + } + public func list() + { + for solution in SettingsManager.shared.solutions + { + print(solution.identifier + ":") + for setting in solution.settings + { + print("\t" + setting.name + " [" + setting.type.rawValue + "]") + } + } + } + public func info(solution: String, preference: String) + { + let setting = SettingsManager.shared.setting(for: Preferences.Key(solution: solution, preference: preference)) + print(setting.debugDescription) + } + public func read(solution: String, preference: String) + { + SettingsManager.shared.capture(valueFor: Preferences.Key(solution: solution, preference: preference)) + { + value in + if(value != nil) + { + print("Value: " + (value as! String)) + } + } + } + public func write(solution: String, preference: String, value: String) + { + let setting = SettingsManager.shared.setting(for: Preferences.Key(solution: solution, preference: preference)) + var data : Interoperable? = nil + switch setting?.type + { + case .boolean: + if(value.lowercased() == "true" || value.lowercased() == "1") + { + data = true + } + else if value.lowercased() == "false" || value.lowercased() == "0" + { + data = false + } + else + { + print("[ERROR]: value not a boolean") + return + } + break + case .double: + if let dbl = Double(value) + { + data = dbl + } + else + { + print("[ERROR]: value not a double") + return + } + break + case .integer: + if let int = Int(value) + { + data = int + } + else + { + print("[ERROR]: value not an integer") + return + } + break + case .string: + data = value + break + case .none: + print("[ERROR]: setting data type invalid") + return + } + if data == nil + { + print("[ERROR]: unknown error processing value") + return + } + SettingsManager.shared.apply(data, for: Preferences.Key(solution: solution, preference: preference)) + { + success in + if success + { + print("Value applied successfully!") + } + } + } +} diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift new file mode 100644 index 00000000..5326cc9f --- /dev/null +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift @@ -0,0 +1,151 @@ +// Copyright 2020 Raising the Floor - International +// +// Licensed under the New BSD license. You may not use this file except in +// compliance with this License. +// +// You may obtain a copy of the License at +// https://github.com/GPII/universal/blob/master/LICENSE.txt +// +// The R&D leading to these results received funding from the: +// * Rehabilitation Services Administration, US Dept. of Education under +// grant H421A150006 (APCP) +// * National Institute on Disability, Independent Living, and +// Rehabilitation Research (NIDILRR) +// * Administration for Independent Living & Dept. of Education under grants +// H133E080022 (RERC-IT) and H133E130028/90RE5003-01-00 (UIITA-RERC) +// * European Union's Seventh Framework Programme (FP7/2007-2013) grant +// agreement nos. 289016 (Cloud4all) and 610510 (Prosperity4All) +// * William and Flora Hewlett Foundation +// * Ontario Ministry of Research and Innovation +// * Canadian Foundation for Innovation +// * Adobe Foundation +// * Consumer Electronics Association Foundation + +import Foundation + +var manager = RegistryManager() +let appname = "morphictest" + +if CommandLine.argc > 2 //run single automated command, do not begin interactive client +{ + if manager.load(registry: CommandLine.arguments[1]) + { + switch CommandLine.arguments[2] { + case "list": + manager.list() + break + case "info": + if(CommandLine.argc != 5) + { + print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] info [solution] [setting]") + } + else + { + manager.info(solution: CommandLine.arguments[3], preference: CommandLine.arguments[4]) + } + break + case "read": + if(CommandLine.argc != 5) + { + print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] read [solution] [setting]") + } + else + { + manager.read(solution: CommandLine.arguments[3], preference: CommandLine.arguments[4]) + } + break + case "write": + if(CommandLine.argc != 6) + { + print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] write [solution] [setting] [value]") + } + else + { + manager.write(solution: CommandLine.arguments[3], preference: CommandLine.arguments[4], value: CommandLine.arguments[5]) + } + break + default: + print("[ERROR]: Unrecognized command. Command list: list, info, read, write") + } + } +} +else +{ + var loaded = false + if CommandLine.argc == 2 + { + loaded = manager.load(registry: CommandLine.arguments[1]) + } + else + { + print("Please input a valid solutions registry JSON file") + } + while(!loaded) + { + let address : String = readLine() ?? "" + loaded = manager.load(registry: address) + } + print("Solutions file loaded successfully.") + var loop = true + while(loop) + { + print("Please enter a command, type 'help' to list all commands:") + let line = readLine() + let args = line?.components(separatedBy: " ") ?? [] + if(args.count > 0) + { + switch args[0] { + case "list": + manager.list() + break + case "info": + if(args.count != 3) + { + print("[ERROR]: Incorrect number of parameters. Use: info [solution] [setting]") + } + else + { + manager.info(solution: args[1], preference: args[2]) + } + break + case "read": + if(args.count != 3) + { + print("[ERROR]: Incorrect number of parameters. Use: read [solution] [setting]") + } + else + { + manager.read(solution: args[1], preference: args[2]) + } + break + case "write": + if(args.count != 4) + { + print("[ERROR]: Incorrect number of parameters. Use: write [solution] [setting] [value]") + } + else + { + manager.write(solution: args[1], preference: args[2], value: args[3]) + } + break + case "help": + print("list:") + print("\tLists all solutions and settings") + print("info [solution] [setting]:") + print("\tGives you info on a particular setting (for now just data type)") + print("read [solution] [setting]:") + print("\tLists the current value of a setting") + print("write [solution] [setting] [value]:") + print("\tChanges the value of a setting, if possible") + print("quit:") + print("\tEnds the program") + break + case "quit": + loop = false + break + default: + print("[ERROR]: Invalid command") + } + } + } +} From 47cba56a4bb80ebf40d8c981792d38463c615e3f Mon Sep 17 00:00:00 2001 From: Christopher - RtF <58520035+christopher-rtf@users.noreply.github.com> Date: Mon, 17 Aug 2020 14:47:53 -0400 Subject: [PATCH 02/12] update code signing, bundle IDs to be consistent with MorphicClient --- MorphicCore/MorphicCore.xcodeproj/project.pbxproj | 2 +- .../MorphicManualTester.xcodeproj/project.pbxproj | 7 ++++--- .../MorphicManualTesterCLI.xcodeproj/project.pbxproj | 4 ++-- MorphicService/MorphicService.xcodeproj/project.pbxproj | 2 +- MorphicSettings/MorphicSettings.xcodeproj/project.pbxproj | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/MorphicCore/MorphicCore.xcodeproj/project.pbxproj b/MorphicCore/MorphicCore.xcodeproj/project.pbxproj index d617d549..75b35176 100644 --- a/MorphicCore/MorphicCore.xcodeproj/project.pbxproj +++ b/MorphicCore/MorphicCore.xcodeproj/project.pbxproj @@ -373,7 +373,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; diff --git a/MorphicManualTester/MorphicManualTester.xcodeproj/project.pbxproj b/MorphicManualTester/MorphicManualTester.xcodeproj/project.pbxproj index 4ec540fc..66bf3b0b 100644 --- a/MorphicManualTester/MorphicManualTester.xcodeproj/project.pbxproj +++ b/MorphicManualTester/MorphicManualTester.xcodeproj/project.pbxproj @@ -339,7 +339,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - PRODUCT_BUNDLE_IDENTIFIER = org.raisingthefloor.MorphicManualTester; + PRODUCT_BUNDLE_IDENTIFIER = "org.raisingthefloor.MorphicManualTester-Debug"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; }; @@ -350,8 +350,8 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = MorphicManualTester/MorphicManualTester.entitlements; - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_IDENTITY = "Developer ID Application"; + CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_ASSET_PATHS = "\"MorphicManualTester/Preview Content\""; DEVELOPMENT_TEAM = 5AAXYGZ428; @@ -365,6 +365,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.15; PRODUCT_BUNDLE_IDENTIFIER = org.raisingthefloor.MorphicManualTester; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; name = Release; diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/project.pbxproj b/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/project.pbxproj index 87c244ef..0ef46a5c 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/project.pbxproj +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/project.pbxproj @@ -281,7 +281,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 5AAXYGZ428; ENABLE_HARDENED_RUNTIME = YES; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -293,7 +293,7 @@ FFF243DD24E7FA660054E3F4 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = "Developer ID Application"; CODE_SIGN_STYLE = Manual; DEVELOPMENT_TEAM = 5AAXYGZ428; ENABLE_HARDENED_RUNTIME = YES; diff --git a/MorphicService/MorphicService.xcodeproj/project.pbxproj b/MorphicService/MorphicService.xcodeproj/project.pbxproj index 20bbbb39..f7047f5d 100644 --- a/MorphicService/MorphicService.xcodeproj/project.pbxproj +++ b/MorphicService/MorphicService.xcodeproj/project.pbxproj @@ -391,7 +391,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; diff --git a/MorphicSettings/MorphicSettings.xcodeproj/project.pbxproj b/MorphicSettings/MorphicSettings.xcodeproj/project.pbxproj index 893809c3..83be6738 100644 --- a/MorphicSettings/MorphicSettings.xcodeproj/project.pbxproj +++ b/MorphicSettings/MorphicSettings.xcodeproj/project.pbxproj @@ -705,7 +705,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; From 80f70a840a04b6bbdfbcf753e29bd6a05807b2e9 Mon Sep 17 00:00:00 2001 From: Christopher - RtF <58520035+christopher-rtf@users.noreply.github.com> Date: Mon, 17 Aug 2020 14:48:37 -0400 Subject: [PATCH 03/12] add runtime path (for console app to consistently find libraries) --- .../MorphicManualTesterCLI.xcodeproj/project.pbxproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/project.pbxproj b/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/project.pbxproj index 0ef46a5c..70afbb03 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/project.pbxproj +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/project.pbxproj @@ -284,6 +284,10 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 5AAXYGZ428; ENABLE_HARDENED_RUNTIME = YES; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path", + ); PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; @@ -297,6 +301,10 @@ CODE_SIGN_STYLE = Manual; DEVELOPMENT_TEAM = 5AAXYGZ428; ENABLE_HARDENED_RUNTIME = YES; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path", + ); PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; From 19456a16cd6ac15463234b2d517385a2472cc32c Mon Sep 17 00:00:00 2001 From: CatalinaTest Date: Wed, 19 Aug 2020 09:03:16 -0700 Subject: [PATCH 04/12] Minor interface tweaks --- .../xcschemes/MorphicManualTesterCLI.xcscheme | 2 +- .../RegistryManager.swift | 4 ++ .../MorphicManualTesterCLI/main.swift | 51 +++++++++++-------- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/xcshareddata/xcschemes/MorphicManualTesterCLI.xcscheme b/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/xcshareddata/xcschemes/MorphicManualTesterCLI.xcscheme index 22925f2b..33aacbfa 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/xcshareddata/xcschemes/MorphicManualTesterCLI.xcscheme +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI.xcodeproj/xcshareddata/xcschemes/MorphicManualTesterCLI.xcscheme @@ -53,7 +53,7 @@ + isEnabled = "NO"> diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift index b327c24d..0d00c8bc 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift @@ -121,6 +121,10 @@ public class RegistryManager { print("Value applied successfully!") } + else + { + print("Value application failed") + } } } } diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift index 5326cc9f..6c25987b 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift @@ -22,6 +22,7 @@ // * Consumer Electronics Association Foundation import Foundation +import Darwin var manager = RegistryManager() let appname = "morphictest" @@ -37,7 +38,7 @@ if CommandLine.argc > 2 //run single automated command, do not begin interactive case "info": if(CommandLine.argc != 5) { - print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] info [solution] [setting]") + print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] info [solution] [preference]") } else { @@ -47,7 +48,7 @@ if CommandLine.argc > 2 //run single automated command, do not begin interactive case "read": if(CommandLine.argc != 5) { - print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] read [solution] [setting]") + print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] read [solution] [preference]") } else { @@ -57,7 +58,7 @@ if CommandLine.argc > 2 //run single automated command, do not begin interactive case "write": if(CommandLine.argc != 6) { - print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] write [solution] [setting] [value]") + print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] write [solution] [preference] [value]") } else { @@ -76,20 +77,22 @@ else { loaded = manager.load(registry: CommandLine.arguments[1]) } - else - { - print("Please input a valid solutions registry JSON file") - } while(!loaded) { + print("Please provide the file path to a valid solutions registry JSON file: ") + print("> ", terminator:"") let address : String = readLine() ?? "" + if(address == "quit" || address == "exit") + { + exit(0) + } loaded = manager.load(registry: address) } print("Solutions file loaded successfully.") - var loop = true - while(loop) + while(true) { print("Please enter a command, type 'help' to list all commands:") + print("> ", terminator:"") let line = readLine() let args = line?.components(separatedBy: " ") ?? [] if(args.count > 0) @@ -101,7 +104,7 @@ else case "info": if(args.count != 3) { - print("[ERROR]: Incorrect number of parameters. Use: info [solution] [setting]") + print("[ERROR]: Incorrect number of parameters. Use: info [solution] [preference]") } else { @@ -111,7 +114,7 @@ else case "read": if(args.count != 3) { - print("[ERROR]: Incorrect number of parameters. Use: read [solution] [setting]") + print("[ERROR]: Incorrect number of parameters. Use: read [solution] [preference]") } else { @@ -121,7 +124,7 @@ else case "write": if(args.count != 4) { - print("[ERROR]: Incorrect number of parameters. Use: write [solution] [setting] [value]") + print("[ERROR]: Incorrect number of parameters. Use: write [solution] [preference] [value]") } else { @@ -130,18 +133,26 @@ else break case "help": print("list:") - print("\tLists all solutions and settings") - print("info [solution] [setting]:") - print("\tGives you info on a particular setting (for now just data type)") - print("read [solution] [setting]:") - print("\tLists the current value of a setting") - print("write [solution] [setting] [value]:") + print("\tLists all solutions and settings from the registry") + print() + print("info [solution] [preference]:") + print("\tGives you info on a particular setting in the registry") + print() + print("read [solution] [preference]:") + print("\tLists the current value of a setting on your system") + print() + print("write [solution] [preference] [value]:") print("\tChanges the value of a setting, if possible") - print("quit:") + print() + print("exit:") print("\tEnds the program") + print() break case "quit": - loop = false + exit(0) + break + case "exit": + exit(0) break default: print("[ERROR]: Invalid command") From cc7f75171599bf89a29a76c49ebf082ae1d0f61c Mon Sep 17 00:00:00 2001 From: CatalinaTest Date: Thu, 20 Aug 2020 06:57:34 -0700 Subject: [PATCH 05/12] added more granular list functionality --- .../RegistryManager.swift | 23 ++++++++++++ .../MorphicManualTesterCLI/main.swift | 37 ++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift index 0d00c8bc..25eba0ac 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift @@ -43,6 +43,29 @@ public class RegistryManager } } } + public func listSolutions() + { + for solution in SettingsManager.shared.solutions + { + print(solution.identifier) + } + } + public func listSpecific(solution: String) + { + for sol in SettingsManager.shared.solutions + { + if sol.identifier == solution + { + print(sol.identifier + ":") + for setting in sol.settings + { + print("\t" + setting.name + " [" + setting.type.rawValue + "]") + } + return + } + } + print("[ERROR]: Solution not found. Please provide list with a solution in the registry, -s for solutions, or no parameter to list all settings.") + } public func info(solution: String, preference: String) { let setting = SettingsManager.shared.setting(for: Preferences.Key(solution: solution, preference: preference)) diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift index 6c25987b..29ed974c 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift @@ -33,7 +33,22 @@ if CommandLine.argc > 2 //run single automated command, do not begin interactive { switch CommandLine.arguments[2] { case "list": - manager.list() + if(CommandLine.argc == 3) + { + manager.list() + } + else if(CommandLine.argc != 4) + { + print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] list [solution], \(appname) [filename] list -s, or \(appname) [filename] list") + } + else if(CommandLine.arguments[3] == "-s") + { + manager.listSolutions() + } + else + { + manager.listSpecific(solution: CommandLine.arguments[3]) + } break case "info": if(CommandLine.argc != 5) @@ -99,7 +114,21 @@ else { switch args[0] { case "list": - manager.list() + if(args.count == 1) + { + manager.list() + } + else if(args.count == 2) + { + if(args[1] == "-s") + { + manager.listSolutions() + } + else + { + manager.listSpecific(solution: args[1]) + } + } break case "info": if(args.count != 3) @@ -134,6 +163,10 @@ else case "help": print("list:") print("\tLists all solutions and settings from the registry") + print("list -s") + print("\tLists all solutions without their settings") + print("list [solution]") + print("\tLists only the settings for a specific solution") print() print("info [solution] [preference]:") print("\tGives you info on a particular setting in the registry") From 8375efaa0d532a220e6b9e447c7b73aa2e8b31eb Mon Sep 17 00:00:00 2001 From: CatalinaTest Date: Thu, 20 Aug 2020 07:29:49 -0700 Subject: [PATCH 06/12] fixed strings --- .../MorphicManualTesterCLI/RegistryManager.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift index 25eba0ac..fb5b0f7b 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift @@ -39,7 +39,7 @@ public class RegistryManager print(solution.identifier + ":") for setting in solution.settings { - print("\t" + setting.name + " [" + setting.type.rawValue + "]") + print("\t\(setting.name) [\(setting.type.rawValue)]") } } } @@ -56,10 +56,10 @@ public class RegistryManager { if sol.identifier == solution { - print(sol.identifier + ":") + print("\(sol.identifier):") for setting in sol.settings { - print("\t" + setting.name + " [" + setting.type.rawValue + "]") + print("\t\(setting.name) [\(setting.type.rawValue)]") } return } @@ -78,7 +78,7 @@ public class RegistryManager value in if(value != nil) { - print("Value: " + (value as! String)) + print("Value: \(value as! String)") } } } From df9b488ed27253c6a3c7a8a3903d49cc9ed5a349 Mon Sep 17 00:00:00 2001 From: CatalinaTest Date: Thu, 20 Aug 2020 07:38:12 -0700 Subject: [PATCH 07/12] fixed read --- .../RegistryManager.swift | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift index fb5b0f7b..b4484cb6 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift @@ -78,7 +78,22 @@ public class RegistryManager value in if(value != nil) { - print("Value: \(value as! String)") + if let sval = value as? String + { + print("Value: \(sval)") + } + else if let bval = value as? Bool + { + print("Value: \(bval ? "true" : "false")") + } + else if let ival = value as? Int + { + print("Value: \(String(ival))") + } + else if let dval = value as? Double + { + print("Value: \(String(dval))") + } } } } From 5f44834fd81cbde87316c1157bf08b8a202af489 Mon Sep 17 00:00:00 2001 From: CatalinaTest Date: Fri, 21 Aug 2020 23:23:31 -0700 Subject: [PATCH 08/12] PR feature fixes --- .../RegistryManager.swift | 20 ++- .../MorphicManualTesterCLI/main.swift | 128 ++++++++++++------ 2 files changed, 101 insertions(+), 47 deletions(-) diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift index b4484cb6..8fee5394 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift @@ -71,7 +71,21 @@ public class RegistryManager let setting = SettingsManager.shared.setting(for: Preferences.Key(solution: solution, preference: preference)) print(setting.debugDescription) } - public func read(solution: String, preference: String) + public func get(solution: String? = nil) + { + let allSolutions = (solution == nil) + for sol in SettingsManager.shared.solutions + { + if(allSolutions || solution == sol.identifier) + { + for setting in sol.settings + { + get(solution: sol.identifier, preference: setting.name) + } + } + } + } + public func get(solution: String, preference: String) { SettingsManager.shared.capture(valueFor: Preferences.Key(solution: solution, preference: preference)) { @@ -97,7 +111,7 @@ public class RegistryManager } } } - public func write(solution: String, preference: String, value: String) + public func set(solution: String, preference: String, value: String) { let setting = SettingsManager.shared.setting(for: Preferences.Key(solution: solution, preference: preference)) var data : Interoperable? = nil @@ -144,7 +158,7 @@ public class RegistryManager data = value break case .none: - print("[ERROR]: setting data type invalid") + print("[ERROR]: not a valid setting, check parameters") return } if data == nil diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift index 29ed974c..329dc79b 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift @@ -37,51 +37,74 @@ if CommandLine.argc > 2 //run single automated command, do not begin interactive { manager.list() } - else if(CommandLine.argc != 4) + else if(CommandLine.argc == 4) { - print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] list [solution], \(appname) [filename] list -s, or \(appname) [filename] list") - } - else if(CommandLine.arguments[3] == "-s") - { - manager.listSolutions() + manager.listSpecific(solution: CommandLine.arguments[3]) } else { - manager.listSpecific(solution: CommandLine.arguments[3]) + print("[ERROR]: Incorrect number of parameters. Use: \(appname) list [solution]") } break + case "listsol": + manager.listSolutions() + break case "info": - if(CommandLine.argc != 5) + if(CommandLine.argc == 5) { - print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] info [solution] [preference]") + manager.info(solution: CommandLine.arguments[3], preference: CommandLine.arguments[4]) } else { - manager.info(solution: CommandLine.arguments[3], preference: CommandLine.arguments[4]) + print("[ERROR]: Incorrect number of parameters. Use: \(appname) info ") } break case "read": - if(CommandLine.argc != 5) + if(CommandLine.argc == 3) { - print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] read [solution] [preference]") + manager.get() + } + else if(CommandLine.argc == 4) + { + manager.get(solution: CommandLine.arguments[3]) + } + else if(CommandLine.argc == 5) + { + manager.get(solution: CommandLine.arguments[3], preference: CommandLine.arguments[4]) } else { - manager.read(solution: CommandLine.arguments[3], preference: CommandLine.arguments[4]) + print("[ERROR]: Incorrect number of parameters. Use: \(appname) get [solution] [preference]") } break case "write": - if(CommandLine.argc != 6) + if(CommandLine.argc == 6) { - print("[ERROR]: Incorrect number of parameters. Use: \(appname) [filename] write [solution] [preference] [value]") + manager.set(solution: CommandLine.arguments[3], preference: CommandLine.arguments[4], value: CommandLine.arguments[5]) } else { - manager.write(solution: CommandLine.arguments[3], preference: CommandLine.arguments[4], value: CommandLine.arguments[5]) + print("[ERROR]: Incorrect number of parameters. Use: \(appname) set ") } break + case "help": + print("\(appname) list [solution]:") + print("\tLists all solutions and settings from the registry, or if provided a solution, only lists settings for that solution") + print("\(appname) listsol") + print("\tLists all solutions without their settings for quick lookup") + print() + print("\(appname) info :") + print("\tGives you verbose info on a particular setting in the registry") + print() + print("\(appname) read [solution] [preference]:") + print("\tLists the current value of a setting, all settings in a solution, or all settings in the registry depending on provided parameters") + print() + print("\(appname) write :") + print("\tChanges the value of a setting, if possible") + print() + break default: - print("[ERROR]: Unrecognized command. Command list: list, info, read, write") + print("[ERROR]: Unrecognized command. Commands: list, listsol, info, get, set, help") } } } @@ -90,7 +113,15 @@ else var loaded = false if CommandLine.argc == 2 { - loaded = manager.load(registry: CommandLine.arguments[1]) + if !manager.load(registry: CommandLine.arguments[1]) + { + print("[ERROR]: Could not load file \(CommandLine.arguments[1]) as a valid solutions registry JSON file. Check filename and try again.") + } + } + else + { + print("[ERROR]: Valid solutions registry file path required. Use: \(appname) ") + exit(0) } while(!loaded) { @@ -104,6 +135,9 @@ else loaded = manager.load(registry: address) } print("Solutions file loaded successfully.") + print("Welcome to the Morphic Manual Solutions Registry Tester.") + print("Morphic is Copyright 2020 Raising the Floor - International") + print() while(true) { print("Please enter a command, type 'help' to list all commands:") @@ -120,61 +154,67 @@ else } else if(args.count == 2) { - if(args[1] == "-s") - { - manager.listSolutions() - } - else - { - manager.listSpecific(solution: args[1]) - } + manager.listSpecific(solution: args[1]) } + else + { + print("[ERROR]: Incorrect number of parameters. Use: list [solution]") + } + break + case "listsol": + manager.listSolutions() break case "info": - if(args.count != 3) + if(args.count == 3) { - print("[ERROR]: Incorrect number of parameters. Use: info [solution] [preference]") + manager.info(solution: args[1], preference: args[2]) } else { - manager.info(solution: args[1], preference: args[2]) + print("[ERROR]: Incorrect number of parameters. Use: info ") } break case "read": - if(args.count != 3) + if(args.count == 1) + { + manager.get() + } + else if(args.count == 2) + { + manager.get(solution: args[1]) + } + else if(args.count == 3) { - print("[ERROR]: Incorrect number of parameters. Use: read [solution] [preference]") + manager.get(solution: args[1], preference: args[2]) } else { - manager.read(solution: args[1], preference: args[2]) + print("[ERROR]: Incorrect number of parameters. Use: get [solution] [preference]") } break case "write": if(args.count != 4) { - print("[ERROR]: Incorrect number of parameters. Use: write [solution] [preference] [value]") + print("[ERROR]: Incorrect number of parameters. Use: set ") } else { - manager.write(solution: args[1], preference: args[2], value: args[3]) + manager.set(solution: args[1], preference: args[2], value: args[3]) } break case "help": - print("list:") - print("\tLists all solutions and settings from the registry") - print("list -s") - print("\tLists all solutions without their settings") - print("list [solution]") - print("\tLists only the settings for a specific solution") + print("list [solution]:") + print("\tLists all solutions and settings from the registry, or if provided a solution, only lists settings for that solution") + print("listsol") + print("\tLists all solutions without their settings for quick lookup") print() - print("info [solution] [preference]:") - print("\tGives you info on a particular setting in the registry") + print("info :") + print("\tGives you verbose info on a particular setting in the registry") print() print("read [solution] [preference]:") - print("\tLists the current value of a setting on your system") + print("\tLists the current value of a setting, all settings in a solution, or all settings in the registry depending on provided parameters") print() - print("write [solution] [preference] [value]:") + print("write :") print("\tChanges the value of a setting, if possible") print() print("exit:") From 03ae90c24757a6ea2dbb5d46316a1482bab3a25e Mon Sep 17 00:00:00 2001 From: CatalinaTest Date: Sat, 22 Aug 2020 07:58:40 -0700 Subject: [PATCH 09/12] another fix --- .../MorphicManualTesterCLI/main.swift | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift index 329dc79b..4bfe786d 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift @@ -110,7 +110,6 @@ if CommandLine.argc > 2 //run single automated command, do not begin interactive } else { - var loaded = false if CommandLine.argc == 2 { if !manager.load(registry: CommandLine.arguments[1]) @@ -123,17 +122,6 @@ else print("[ERROR]: Valid solutions registry file path required. Use: \(appname) ") exit(0) } - while(!loaded) - { - print("Please provide the file path to a valid solutions registry JSON file: ") - print("> ", terminator:"") - let address : String = readLine() ?? "" - if(address == "quit" || address == "exit") - { - exit(0) - } - loaded = manager.load(registry: address) - } print("Solutions file loaded successfully.") print("Welcome to the Morphic Manual Solutions Registry Tester.") print("Morphic is Copyright 2020 Raising the Floor - International") From cbfa23d86e82321a810d66b2d09f95c4d2b0ff7f Mon Sep 17 00:00:00 2001 From: CatalinaTest Date: Sat, 22 Aug 2020 11:31:38 -0700 Subject: [PATCH 10/12] reorganized setup --- .../RegistryManager.swift | 10 +- .../MorphicManualTesterCLI/main.swift | 268 ++++++++---------- 2 files changed, 131 insertions(+), 147 deletions(-) diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift index 8fee5394..72175a51 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift @@ -78,8 +78,10 @@ public class RegistryManager { if(allSolutions || solution == sol.identifier) { + print("\(sol.identifier):") for setting in sol.settings { + print("\t\(setting.name): ", terminator:"") get(solution: sol.identifier, preference: setting.name) } } @@ -94,19 +96,19 @@ public class RegistryManager { if let sval = value as? String { - print("Value: \(sval)") + print("[string] value: \(sval)") } else if let bval = value as? Bool { - print("Value: \(bval ? "true" : "false")") + print("[bool] value: \(bval ? "true" : "false")") } else if let ival = value as? Int { - print("Value: \(String(ival))") + print("[int] value: \(String(ival))") } else if let dval = value as? Double { - print("Value: \(String(dval))") + print("[double] value: \(String(dval))") } } } diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift index 4bfe786d..5dd53cc3 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift @@ -22,7 +22,6 @@ // * Consumer Electronics Association Foundation import Foundation -import Darwin var manager = RegistryManager() let appname = "morphictest" @@ -31,24 +30,20 @@ if CommandLine.argc > 2 //run single automated command, do not begin interactive { if manager.load(registry: CommandLine.arguments[1]) { - switch CommandLine.arguments[2] { + switch CommandLine.arguments[2] + { case "list": - if(CommandLine.argc == 3) + switch CommandLine.argc { + case 3: manager.list() - } - else if(CommandLine.argc == 4) - { + case 4: manager.listSpecific(solution: CommandLine.arguments[3]) - } - else - { + default: print("[ERROR]: Incorrect number of parameters. Use: \(appname) list [solution]") } - break case "listsol": manager.listSolutions() - break case "info": if(CommandLine.argc == 5) { @@ -58,26 +53,19 @@ if CommandLine.argc > 2 //run single automated command, do not begin interactive { print("[ERROR]: Incorrect number of parameters. Use: \(appname) info ") } - break - case "read": - if(CommandLine.argc == 3) + case "get": + switch CommandLine.argc { + case 3: manager.get() - } - else if(CommandLine.argc == 4) - { + case 4: manager.get(solution: CommandLine.arguments[3]) - } - else if(CommandLine.argc == 5) - { + case 5: manager.get(solution: CommandLine.arguments[3], preference: CommandLine.arguments[4]) - } - else - { + default: print("[ERROR]: Incorrect number of parameters. Use: \(appname) get [solution] [preference]") } - break - case "write": + case "set": if(CommandLine.argc == 6) { manager.set(solution: CommandLine.arguments[3], preference: CommandLine.arguments[4], value: CommandLine.arguments[5]) @@ -86,138 +74,132 @@ if CommandLine.argc > 2 //run single automated command, do not begin interactive { print("[ERROR]: Incorrect number of parameters. Use: \(appname) set ") } - break - case "help": - print("\(appname) list [solution]:") - print("\tLists all solutions and settings from the registry, or if provided a solution, only lists settings for that solution") - print("\(appname) listsol") - print("\tLists all solutions without their settings for quick lookup") - print() - print("\(appname) info :") - print("\tGives you verbose info on a particular setting in the registry") - print() - print("\(appname) read [solution] [preference]:") - print("\tLists the current value of a setting, all settings in a solution, or all settings in the registry depending on provided parameters") - print() - print("\(appname) write :") - print("\tChanges the value of a setting, if possible") - print() - break + case "help": + helpdoc(cmdline: true) default: print("[ERROR]: Unrecognized command. Commands: list, listsol, info, get, set, help") } } + else + { + print("[ERROR]: Could not load file \(CommandLine.arguments[1]) as a valid solutions registry JSON file. Check filename and try again.") + } } -else +else if(CommandLine.argc == 2) { - if CommandLine.argc == 2 + if manager.load(registry: CommandLine.arguments[1]) { - if !manager.load(registry: CommandLine.arguments[1]) + print("\u{001B}[2J") + print("Solutions file loaded successfully.") + print("Welcome to the Morphic Manual Solutions Registry Tester.") + print("Morphic is Copyright 2020 Raising the Floor - International") + print() + var loop = true + while(loop) { - print("[ERROR]: Could not load file \(CommandLine.arguments[1]) as a valid solutions registry JSON file. Check filename and try again.") + print("Please enter a command, type 'help' to list all commands:") + print("> ", terminator:"") + let line = readLine() + let args = line?.components(separatedBy: " ") ?? [] + if(args.count > 0) + { + switch args[0] { + case "list": + switch args.count + { + case 1: + manager.list() + case 2: + manager.listSpecific(solution: args[1]) + default: + print("[ERROR]: Incorrect number of parameters. Use: list [solution]") + } + case "listsol": + manager.listSolutions() + case "info": + if(args.count == 3) + { + manager.info(solution: args[1], preference: args[2]) + } + else + { + print("[ERROR]: Incorrect number of parameters. Use: info ") + } + case "get": + switch args.count + { + case 1: + manager.get() + case 2: + manager.get(solution: args[1]) + case 3: + manager.get(solution: args[1], preference: args[2]) + default: + print("[ERROR]: Incorrect number of parameters. Use: get [solution] [preference]") + } + case "set": + if(args.count != 4) + { + print("[ERROR]: Incorrect number of parameters. Use: set ") + } + else + { + manager.set(solution: args[1], preference: args[2], value: args[3]) + } + case "help": + helpdoc(cmdline: false) + case "quit": + loop = false + case "exit": + loop = false + default: + print("[ERROR]: Invalid command") + } + } } } + else if CommandLine.arguments[1] == "help" + { + helpdoc(cmdline: true) + } else { - print("[ERROR]: Valid solutions registry file path required. Use: \(appname) ") - exit(0) + print("[ERROR]: Could not load file \(CommandLine.arguments[1]) as a valid solutions registry JSON file. Check filename and try again.") } - print("Solutions file loaded successfully.") - print("Welcome to the Morphic Manual Solutions Registry Tester.") - print("Morphic is Copyright 2020 Raising the Floor - International") +} +else +{ + print("[ERROR]: Valid solutions registry file path required. Use: \(appname) ") +} + +func helpdoc(cmdline: Bool) +{ + print("\u{001B}[2J") + var header = "" + if cmdline + { + header = "\(appname) " + } + print("\t\(header)list [solution]:") + print("Lists all solutions and settings from the registry, or if provided a solution, only lists settings for that solution") + print() + print("\t\(header)listsol") + print("Lists all solutions without their settings for quick lookup") print() - while(true) + print("\t\(header)info :") + print("Gives you verbose info on a particular setting in the registry") + print() + print("\t\(header)get [solution] [preference]:") + print("Lists the current value of a setting, all settings in a solution, or all settings in the registry depending on provided parameters") + print() + print("\t\(header)set :") + print("Changes the value of a setting, if possible") + print() + if cmdline { - print("Please enter a command, type 'help' to list all commands:") - print("> ", terminator:"") - let line = readLine() - let args = line?.components(separatedBy: " ") ?? [] - if(args.count > 0) - { - switch args[0] { - case "list": - if(args.count == 1) - { - manager.list() - } - else if(args.count == 2) - { - manager.listSpecific(solution: args[1]) - } - else - { - print("[ERROR]: Incorrect number of parameters. Use: list [solution]") - } - break - case "listsol": - manager.listSolutions() - break - case "info": - if(args.count == 3) - { - manager.info(solution: args[1], preference: args[2]) - } - else - { - print("[ERROR]: Incorrect number of parameters. Use: info ") - } - break - case "read": - if(args.count == 1) - { - manager.get() - } - else if(args.count == 2) - { - manager.get(solution: args[1]) - } - else if(args.count == 3) - { - manager.get(solution: args[1], preference: args[2]) - } - else - { - print("[ERROR]: Incorrect number of parameters. Use: get [solution] [preference]") - } - break - case "write": - if(args.count != 4) - { - print("[ERROR]: Incorrect number of parameters. Use: set ") - } - else - { - manager.set(solution: args[1], preference: args[2], value: args[3]) - } - break - case "help": - print("list [solution]:") - print("\tLists all solutions and settings from the registry, or if provided a solution, only lists settings for that solution") - print("listsol") - print("\tLists all solutions without their settings for quick lookup") - print() - print("info :") - print("\tGives you verbose info on a particular setting in the registry") - print() - print("read [solution] [preference]:") - print("\tLists the current value of a setting, all settings in a solution, or all settings in the registry depending on provided parameters") - print() - print("write :") - print("\tChanges the value of a setting, if possible") - print() - print("exit:") - print("\tEnds the program") - print() - break - case "quit": - exit(0) - break - case "exit": - exit(0) - break - default: - print("[ERROR]: Invalid command") - } - } + return } + print("\texit:") + print("Ends the program") + print() } From 963611cc32723f1dfe41b25ed4cf41b7b3e31dc3 Mon Sep 17 00:00:00 2001 From: CatalinaTest Date: Mon, 24 Aug 2020 18:29:59 -0700 Subject: [PATCH 11/12] minor fix --- .../MorphicManualTesterCLI/RegistryManager.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift index 72175a51..6bb0b8a4 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift @@ -36,7 +36,7 @@ public class RegistryManager { for solution in SettingsManager.shared.solutions { - print(solution.identifier + ":") + print("\(solution.identifier):") for setting in solution.settings { print("\t\(setting.name) [\(setting.type.rawValue)]") @@ -64,7 +64,7 @@ public class RegistryManager return } } - print("[ERROR]: Solution not found. Please provide list with a solution in the registry, -s for solutions, or no parameter to list all settings.") + print("[ERROR]: Solution not found. Please provide list command with a solution in the registry or no parameter to list all settings.") } public func info(solution: String, preference: String) { From a886edfeb64c8c531a006b3bf2d51cd99126c619 Mon Sep 17 00:00:00 2001 From: CatalinaTest Date: Sun, 30 Aug 2020 22:44:05 -0700 Subject: [PATCH 12/12] feature fixes --- .../RegistryManager.swift | 10 ++--- .../MorphicManualTesterCLI/main.swift | 37 +++++++++++-------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift index 6bb0b8a4..aa92ec2e 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/RegistryManager.swift @@ -111,6 +111,10 @@ public class RegistryManager print("[double] value: \(String(dval))") } } + else + { + print("[ERROR]: Failed to retrieve value") + } } } public func set(solution: String, preference: String, value: String) @@ -133,7 +137,6 @@ public class RegistryManager print("[ERROR]: value not a boolean") return } - break case .double: if let dbl = Double(value) { @@ -144,7 +147,6 @@ public class RegistryManager print("[ERROR]: value not a double") return } - break case .integer: if let int = Int(value) { @@ -155,10 +157,8 @@ public class RegistryManager print("[ERROR]: value not an integer") return } - break case .string: data = value - break case .none: print("[ERROR]: not a valid setting, check parameters") return @@ -177,7 +177,7 @@ public class RegistryManager } else { - print("Value application failed") + print("[ERROR]: Value application failed") } } } diff --git a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift index 5dd53cc3..4e6d94ce 100644 --- a/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift +++ b/MorphicManualTesterCLI/MorphicManualTesterCLI/main.swift @@ -42,7 +42,7 @@ if CommandLine.argc > 2 //run single automated command, do not begin interactive default: print("[ERROR]: Incorrect number of parameters. Use: \(appname) list [solution]") } - case "listsol": + case "listsolutions": manager.listSolutions() case "info": if(CommandLine.argc == 5) @@ -77,7 +77,7 @@ if CommandLine.argc > 2 //run single automated command, do not begin interactive case "help": helpdoc(cmdline: true) default: - print("[ERROR]: Unrecognized command. Commands: list, listsol, info, get, set, help") + print("[ERROR]: Unrecognized command. Commands: list, listsolutions, info, get, set, help") } } else @@ -89,10 +89,10 @@ else if(CommandLine.argc == 2) { if manager.load(registry: CommandLine.arguments[1]) { - print("\u{001B}[2J") + print("Morphic Manual Solutions Registry Tester") + print("Copyright 2020 Raising the Floor - International") + print() print("Solutions file loaded successfully.") - print("Welcome to the Morphic Manual Solutions Registry Tester.") - print("Morphic is Copyright 2020 Raising the Floor - International") print() var loop = true while(loop) @@ -114,7 +114,7 @@ else if(CommandLine.argc == 2) default: print("[ERROR]: Incorrect number of parameters. Use: list [solution]") } - case "listsol": + case "listsolutions": manager.listSolutions() case "info": if(args.count == 3) @@ -174,32 +174,37 @@ else func helpdoc(cmdline: Bool) { - print("\u{001B}[2J") var header = "" if cmdline { header = "\(appname) " + print("Morphic Manual Solutions Registry Tester") + print("Copyright 2020 Raising the Floor - International") + print() } - print("\t\(header)list [solution]:") - print("Lists all solutions and settings from the registry, or if provided a solution, only lists settings for that solution") - print() - print("\t\(header)listsol") + print("\t\(header)listsolutions") print("Lists all solutions without their settings for quick lookup") print() - print("\t\(header)info :") + print("\t\(header)list") + print("\t\(header)list ") + print("Lists all solutions and settings from the registry, or if provided a solution, only lists settings for that solution") + print() + print("\t\(header)info ") print("Gives you verbose info on a particular setting in the registry") print() - print("\t\(header)get [solution] [preference]:") - print("Lists the current value of a setting, all settings in a solution, or all settings in the registry depending on provided parameters") + print("\t\(header)get") + print("\t\(header)get ") + print("\t\(header)get ") + print("Displays the current value of a setting, all settings in a solution, or all settings in the registry depending on provided parameters") print() - print("\t\(header)set :") + print("\t\(header)set ") print("Changes the value of a setting, if possible") print() if cmdline { return } - print("\texit:") + print("\texit") print("Ends the program") print() }