Skip to content

Commit

Permalink
Merge pull request #14 from MarvinNazari/master
Browse files Browse the repository at this point in the history
Added option for organization name
  • Loading branch information
JohnSundell authored Nov 21, 2016
2 parents 5b6ad7c + b53c1bd commit 981e9da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Template/{PROJECT}.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0810;
ORGANIZATIONNAME = "John Sundell";
ORGANIZATIONNAME = "{ORGANIZATION}";
TargetAttributes = {
52D6D97B1BEFF229002C0205 = {
CreatedOnToolsVersion = 7.1;
Expand Down
15 changes: 12 additions & 3 deletions main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ class StringReplacer {
private let authorEmail: String
private let gitHubURL: String
private let year: String

init(projectName: String, authorName: String, authorEmail: String?, gitHubURL: String?) {
private let organizationName: String

init(projectName: String, authorName: String, authorEmail: String?, gitHubURL: String?, organizationName: String?) {
self.projectName = projectName
self.authorName = authorName
self.authorEmail = authorEmail ?? ""
self.gitHubURL = gitHubURL ?? ""
self.organizationName = organizationName ?? projectName

let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "YYYY"
Expand All @@ -83,6 +85,7 @@ class StringReplacer {
.replacingOccurrences(of: "{EMAIL}", with: authorEmail)
.replacingOccurrences(of: "{URL}", with: gitHubURL)
.replacingOccurrences(of: "{YEAR}", with: year)
.replacingOccurrences(of: "{ORGANIZATION}", with: organizationName)
}

func process(filesInFolderWithPath folderPath: String) throws {
Expand Down Expand Up @@ -192,6 +195,7 @@ let projectName = askForRequiredInfo(question: "📛 What's the name of your pr
let authorName = askForRequiredInfo(question: "👶 What's your name?", errorMessage: "Your name cannot be empty")
let authorEmail = askForOptionalInfo(question: "📫 What's your email address (for Podspec)?")
let gitHubURL = askForOptionalInfo(question: "🌍 Any GitHub URL that you'll be hosting this project at (for Podspec)?")
let organizationName = askForOptionalInfo(question: "🏢 What's your organization name?")

print("---------------------------------------------------------------------")
print("SwiftPlate will now generate a project with the following parameters:")
Expand All @@ -207,6 +211,10 @@ if let gitHubURL = gitHubURL {
print("🌍 GitHub URL: \(gitHubURL)")
}

if let organizationName = organizationName {
print("🏢 Organization Name: \(organizationName)")
}

print("---------------------------------------------------------------------")

if !askForBooleanInfo(question: "Proceed? ✅") {
Expand Down Expand Up @@ -250,7 +258,8 @@ do {
projectName: projectName,
authorName: authorName,
authorEmail: authorEmail,
gitHubURL: gitHubURL
gitHubURL: gitHubURL,
organizationName: organizationName
)

try replacer.process(filesInFolderWithPath: destination)
Expand Down

0 comments on commit 981e9da

Please sign in to comment.