main.swift 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. import ArgumentParser
  15. import Foundation
  16. struct PrivacyManifestGenerator: ParsableCommand {
  17. @Argument(
  18. help: ArgumentHelp("The xcframework to create the Privacy Manifest for."),
  19. transform: URL.init(fileURLWithPath:)
  20. )
  21. var xcframework: URL
  22. func validate() throws {
  23. guard xcframework.pathExtension == "xcframework" else {
  24. throw ValidationError("Given path does not end in `.xcframework`: \(xcframework.path)")
  25. }
  26. }
  27. func run() throws {
  28. let wizard = PrivacyManifestWizard.makeWizard(xcframework: xcframework)
  29. while let question = wizard.nextQuestion() {
  30. print(question)
  31. if let answer = readLine() {
  32. try wizard.processAnswer(answer)
  33. }
  34. }
  35. let privacyManifest = try wizard.createManifest()
  36. print(privacyManifest)
  37. }
  38. }