Skip to content

Commit

Permalink
* temp remove install cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Jintin committed Jan 18, 2017
1 parent d45a4b1 commit fa2bcc3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
2 changes: 0 additions & 2 deletions Swimat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
2F6D8C0C1E0435CA006CFC50 /* ErrorHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F6D8C091E0435CA006CFC50 /* ErrorHandling.swift */; };
2F6D8C0D1E0435CA006CFC50 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F6D8C0A1E0435CA006CFC50 /* main.swift */; };
2F6D8C0E1E0435CA006CFC50 /* OptionParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F6D8C0B1E0435CA006CFC50 /* OptionParser.swift */; };
492A76BF1E22E63700DB9138 /* swimat in Embed Command Line Tool */ = {isa = PBXBuildFile; fileRef = 492C68831E0078A200E64B68 /* swimat */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
492A76C31E23575200DB9138 /* SwimatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 492A76C21E23575200DB9138 /* SwimatViewController.swift */; };
494A4CD41E29E8700071EB7C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 494A4CD21E29E8700071EB7C /* Main.storyboard */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -80,7 +79,6 @@
dstPath = "$(CODESIGNING_FOLDER_PATH)/Contents/Helpers";
dstSubfolderSpec = 0;
files = (
492A76BF1E22E63700DB9138 /* swimat in Embed Command Line Tool */,
);
name = "Embed Command Line Tool";
runOnlyForDeploymentPostprocessing = 0;
Expand Down
6 changes: 3 additions & 3 deletions Swimat/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D25a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="HFN-HU-Szk">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="HFN-HU-Szk">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
Expand Down Expand Up @@ -78,15 +78,15 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="1" verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="h5M-I6-Vzd">
<textField hidden="YES" horizontalHuggingPriority="1" verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="h5M-I6-Vzd">
<rect key="frame" x="-2" y="29" width="344" height="38"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Swimat also comes with a handy command line tool:" id="X5R-Nv-xVX">
<font key="font" metaFont="system" size="15"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="9nB-vh-mrK">
<button hidden="YES" verticalHuggingPriority="750" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="9nB-vh-mrK">
<rect key="frame" x="68" y="-7" width="225" height="32"/>
<buttonCell key="cell" type="push" title="Install swimat to /usr/local/bin/" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="iv2-Fx-fy7">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
Expand Down
48 changes: 24 additions & 24 deletions Swimat/SwimatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,32 @@ class SwimatViewController: NSViewController {

@IBAction func install(_ sender: Any) {
// Migrate this to SMJobBless?
let path = Bundle.main.bundleURL
.appendingPathComponent("Contents", isDirectory: true)
.appendingPathComponent("Helpers", isDirectory: true)
.appendingPathComponent("swimat")
.path
var error: NSDictionary?
let script = NSAppleScript(source: "do shell script \"ln -s \'\(path)\' \(installPath)swimat\" with administrator privileges")
script?.executeAndReturnError(&error)
if error != nil {
let alert = NSAlert()
alert.messageText = "There was an error symlinking swimat."
alert.informativeText = "You can try manually linking swimat by running:\n\nln -s /Applications/Swimat.app/Contents/Helpers/swimat \(installPath)swimat"
alert.alertStyle = .warning
alert.runModal()
}
refreshInstallButton()
// let path = Bundle.main.bundleURL
// .appendingPathComponent("Contents", isDirectory: true)
// .appendingPathComponent("Helpers", isDirectory: true)
// .appendingPathComponent("swimat")
// .path
// var error: NSDictionary?
// let script = NSAppleScript(source: "do shell script \"ln -s \'\(path)\' \(installPath)swimat\" with administrator privileges")
// script?.executeAndReturnError(&error)
// if error != nil {
// let alert = NSAlert()
// alert.messageText = "There was an error symlinking swimat."
// alert.informativeText = "You can try manually linking swimat by running:\n\nln -s /Applications/Swimat.app/Contents/Helpers/swimat \(installPath)swimat"
// alert.alertStyle = .warning
// alert.runModal()
// }
// refreshInstallButton()
}

func refreshInstallButton() {
// Check for swimat, fileExists(atPath:) returns false for symlinks
if ((try? FileManager.default.attributesOfItem(atPath: "\(installPath)swimat")) != nil) {
installButton.title = "swimat installed to \(installPath)"
installButton.isEnabled = false
} else {
installButton.title = "Install swimat to \(installPath)"
installButton.isEnabled = true
}
// // Check for swimat, fileExists(atPath:) returns false for symlinks
// if ((try? FileManager.default.attributesOfItem(atPath: "\(installPath)swimat")) != nil) {
// installButton.title = "swimat installed to \(installPath)"
// installButton.isEnabled = false
// } else {
// installButton.title = "Install swimat to \(installPath)"
// installButton.isEnabled = true
// }
}
}

0 comments on commit fa2bcc3

Please sign in to comment.