   
   /// User select xctemplate
   var templateName: String = templates[0]
- 
+  
   while true {
     print("Select template number : ", terminator: "")
     let input = readLine() ?? "0"

      print("Wrong Value\n")
      continue
    }

    switch num {
    case 0:
      if isRootUserWithSudoCommand(selectNumber: 0) {
        print("CustomTemplate must be executed without sudo command")
        return
      }
      break
    case 1:
      if isRootUserWithSudoCommand(selectNumber: 1) {
        print("CustomTemplate must be executed without sudo command")
        return
      }
      pathEndPoint = "/Library/Developer/Xcode/Templates/Project Templates/Custom"
      directoryPath = customTemplatePath
    case 2:
      if !isRootUserWithSudoCommand(selectNumber: 2) {
        print("XcodeTemplatePath need to be executed with sudo command")
        return
      }
      pathEndPoint = "/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Source"
      directoryPath = XcodeTemplatePath
    case 3:
      if !isRootUserWithSudoCommand(selectNumber: 3) {
        print("XcodeTemplatePath need to be executed with sudo command")
        return
      }
      pathEndPoint = "/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application"
      directoryPath = XcodeTemplatePath
    default:
      break
    }

    directoryPath.append(pathEndPoint)

    printInConsole("Template will be installed at \(directoryPath)")
    break
  }


  let filePath = directoryPath.appending("/\(templateName)")

  do {
    let _ = bash(command: "mkdir", arguments: ["-p", directoryPath])
    

//  Copyright © 2017 giftbott. All rights reserved.
//


import Foundation

let fileManager = FileManager.default

/// Should select template only if more than one
func setup() {
  let templateChecker = try? fileManager
    .contentsOfDirectory(atPath: ".")
    .filter { $0.hasSuffix(".xctemplate") }
  
  guard let templates = templateChecker, templates.count > 0 else {
    printInConsole("xctemplate directory does not exist")
    return
  }
  
  guard templates.count > 1 else {
    installTemplate(templates[0])
    return
  }
  
  /// Show xctemplates in current directory
