         }
         menu.addItem(syncMenuItem)
         menu.addItem(NSMenuItem.separator())
+        menu.addItem(configRepoMenuItem)
+        menu.addItem(configGithubAPIUrlMenuItem)
+        menu.addItem(configGithubTokenMenuItem)
+        menu.addItem(configShowMenuItem)
+        menu.addItem(configResetMenuItem)
         menu.addItem(quitMenuItem)
         menu.delegate = self
         statusItem.menu = menu
-        
-        sync(sender: self)
-        
-//        let myPopup: NSAlert = NSAlert()
-//        myPopup.messageText = "environment"
-//        myPopup.informativeText = ProcessInfo.processInfo.environment.description
-//        myPopup.alertStyle = NSAlert.Style.warning
-//        myPopup.addButton(withTitle: "OK")
-//        myPopup.runModal()
     }
 
     func applicationWillTerminate(_ aNotification: Notification) {


extension AppDelegate: NSMenuDelegate {
    func menuWillOpen(_ menu: NSMenu) {
        if isSyncing {
            syncMenuItem.title = "Sync (Syncing)"
        } else {
            syncMenuItem.title = "Sync (Last Sync: \(lastSyncDate.timeAgo))"
        }
    }
}

                self.completedSyncing()
            }
        }
    }
    
    @objc
    func showRepoConfig(sender: AnyObject) {
        if let repo = self.showConfig(with: "Enter repo:", and: "git@github.com:ivanfoong/xcode-swift-snippets.git") {
            self.repo = repo
        }
    }
    
    @objc
    func showGithubAPIUrlConfig(sender: AnyObject) {
        if let githubAPIUrl = self.showConfig(with: "Enter Github API Url:", and: "https://api.github.com/repos/ivanfoong/xcode-swift-snippets") {
            self.githubAPIUrl = githubAPIUrl
        }
    }
    
    @objc
    func showGithubTokenConfig(sender: AnyObject) {
        if let githubToken = self.showConfig(with: "Enter Github Token:", and: "Token") {
            self.githubToken = githubToken
        }
    }
    
    @objc
    func resetConfig(sender: AnyObject) {
        self.resetConfig()
    }
    
    @objc
    func showCurrentConfig(sender: AnyObject) {
        self.showCurrentConfig()
    }
    
    private func showConfig(with message: String, and placeholder: String) -> String? {
        let a = NSAlert()
        a.messageText = message
        a.addButton(withTitle: "Save")
        a.addButton(withTitle: "Cancel")
        
        let inputTextField = NSTextField(frame: NSRect(x: 0, y: 0, width: 300, height: 24))
        inputTextField.placeholderString = placeholder
        a.accessoryView = inputTextField
        let response = a.runModal()
        switch response {
        case .alertFirstButtonReturn: //Save
            let enteredString = inputTextField.stringValue
            print("Entered string = \"\(enteredString)\"")
            return enteredString
        case .alertSecondButtonReturn: //Cancel
            break
        default:
            break
        }
        return nil
    }
    
    private func resetConfig() {
        UserDefaults.standard.set(nil, forKey: Const.UserDefaults.repo.rawValue)
        UserDefaults.standard.set(nil, forKey: Const.UserDefaults.githubToken.rawValue)
        UserDefaults.standard.set(nil, forKey: Const.UserDefaults.githubAPIUrl.rawValue)
    }
    
    private func showCurrentConfig() {
        let myPopup: NSAlert = NSAlert()
        myPopup.messageText = "Current Config"
        myPopup.informativeText = "Repo: \(self.repo)\nGithub API Url: \(self.githubAPIUrl)\nGithub Token: \(self.githubToken)"
        myPopup.alertStyle = NSAlert.Style.warning
        myPopup.addButton(withTitle: "OK")
        myPopup.runModal()
    }
    
    private func completedSyncing() {
