Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new command line option -environment to allow server selection #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Sources/lola/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import LolaCore
-json "{ \"aps\": {\"alert\": \"Hi from lola 👋\", \"sound\": \"default\" }}"
*/

// Parse commend arguments
// Parse command arguments
let commands = CommandLine.commands

var server: APNSServer = .development

guard let authKey = commands["-authKey"] else {
print("Missing required argument `-authKey` please use format of full name of your file f.e. `AuthKey_JP8Z7XXKD9.p8`")
exit(-1)
Expand All @@ -43,6 +45,17 @@ guard let bundleId = commands["-bundleId"] else {
exit(-1)
}

if let environment = commands["-environment"] {
if environment == "production" {
server = .production
} else if environment == "development" {
server = .development
} else {
print("Environment must be either 'production' or 'development'")
exit(-1)
}
}

// Create token from p8 file
let parser = try P8Parser(
p8: authKey,
Expand All @@ -58,7 +71,7 @@ let configuration = AppConfiguration(
)

// Setup lola
let lola = Lola(configuration: configuration)
let lola = Lola(configuration: configuration, server: server)

let dispatchGroup = DispatchGroup()

Expand Down