Skip to content

Commit

Permalink
UI: New window for installing command line tool
Browse files Browse the repository at this point in the history
Let's see if Apple would accept that!
  • Loading branch information
vashpan committed Mar 7, 2024
1 parent 634d98c commit 035b7f4
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 27 deletions.
16 changes: 16 additions & 0 deletions DevCleaner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
71A21A0E20544CA300B55651 /* XcodeFileEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71A21A0D20544CA300B55651 /* XcodeFileEntry.swift */; };
71A2C1202668FB1200F502A0 /* FeedbackMailer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71A2C11F2668FB1200F502A0 /* FeedbackMailer.swift */; };
71AAD2A32316A99F00D6B133 /* dev-cleaner.sh in Resources */ = {isa = PBXBuildFile; fileRef = 71AAD2A22316A99F00D6B133 /* dev-cleaner.sh */; };
71AC3EB52B991024002B21A7 /* CommandLineInstall.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 71AC3EB42B991024002B21A7 /* CommandLineInstall.storyboard */; };
71AC3EB72B991194002B21A7 /* CommandLineInstallViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71AC3EB62B991194002B21A7 /* CommandLineInstallViewController.swift */; };
71AE37EF23776AFB009C03BB /* FileManager+DateProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71AE37EE23776AFB009C03BB /* FileManager+DateProperties.swift */; };
71AE37F1237A1FAE009C03BB /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 71AE37F0237A1FAE009C03BB /* WebKit.framework */; };
71B01E8E20824F2A00940041 /* XcodeEntryCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71B01E8D20824F2A00940041 /* XcodeEntryCellView.swift */; };
Expand Down Expand Up @@ -102,6 +104,8 @@
71A21A0D20544CA300B55651 /* XcodeFileEntry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XcodeFileEntry.swift; sourceTree = "<group>"; };
71A2C11F2668FB1200F502A0 /* FeedbackMailer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbackMailer.swift; sourceTree = "<group>"; };
71AAD2A22316A99F00D6B133 /* dev-cleaner.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "dev-cleaner.sh"; sourceTree = "<group>"; };
71AC3EB42B991024002B21A7 /* CommandLineInstall.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CommandLineInstall.storyboard; sourceTree = "<group>"; };
71AC3EB62B991194002B21A7 /* CommandLineInstallViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandLineInstallViewController.swift; sourceTree = "<group>"; };
71AE37EE23776AFB009C03BB /* FileManager+DateProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileManager+DateProperties.swift"; sourceTree = "<group>"; };
71AE37F0237A1FAE009C03BB /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
71B01E8D20824F2A00940041 /* XcodeEntryCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XcodeEntryCellView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -238,6 +242,7 @@
71743ECA2078147B00EC0FE2 /* View Controllers */ = {
isa = PBXGroup;
children = (
71AC3EB32B990FD1002B21A7 /* Command Line Install Window */,
7140B61B231BE5C5005768A7 /* Help Window */,
7162E1272097622B00081E4E /* Preferences Window */,
71743ECB207815D300EC0FE2 /* Main Window */,
Expand Down Expand Up @@ -303,6 +308,15 @@
path = Model;
sourceTree = "<group>";
};
71AC3EB32B990FD1002B21A7 /* Command Line Install Window */ = {
isa = PBXGroup;
children = (
71AC3EB42B991024002B21A7 /* CommandLineInstall.storyboard */,
71AC3EB62B991194002B21A7 /* CommandLineInstallViewController.swift */,
);
path = "Command Line Install Window";
sourceTree = "<group>";
};
71B01E8C20824F0F00940041 /* Views */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -401,6 +415,7 @@
files = (
7162E1292097624600081E4E /* Preferences.storyboard in Resources */,
71AAD2A32316A99F00D6B133 /* dev-cleaner.sh in Resources */,
71AC3EB52B991024002B21A7 /* CommandLineInstall.storyboard in Resources */,
7110B4962030F17B00EDBFA3 /* Assets.xcassets in Resources */,
7110B4992030F17B00EDBFA3 /* Main.storyboard in Resources */,
7140B61D231BE5FB005768A7 /* Help.storyboard in Resources */,
Expand Down Expand Up @@ -437,6 +452,7 @@
718D4ABC2311DE66001E9382 /* ArgumentsParser.swift in Sources */,
71E7F836214E8D4400A11601 /* URL+AcquireAccessFromSandbox.swift in Sources */,
71E7F838214E930500A11601 /* Alerts.swift in Sources */,
71AC3EB72B991194002B21A7 /* CommandLineInstallViewController.swift in Sources */,
719B25DC205EF9D7007560C0 /* FileManager+DirectorySize.swift in Sources */,
7162E1262097255C00081E4E /* Stack.swift in Sources */,
71A21A0E20544CA300B55651 /* XcodeFileEntry.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="IOw-Tz-miv">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Window Controller-->
<scene sceneID="dtG-ri-Hu0">
<objects>
<windowController id="IOw-Tz-miv" sceneMemberID="viewController">
<window key="window" title="Install Command Line Tool" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="PcP-Ci-hIX">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="360" y="1160" width="550" height="180"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1682"/>
<value key="minSize" type="size" width="550" height="180"/>
<value key="maxSize" type="size" width="550" height="180"/>
<view key="contentView" id="NmM-SC-cKJ">
<rect key="frame" x="0.0" y="0.0" width="550" height="180"/>
<autoresizingMask key="autoresizingMask"/>
</view>
<connections>
<outlet property="delegate" destination="IOw-Tz-miv" id="eJY-MH-p03"/>
</connections>
</window>
<connections>
<segue destination="yq5-bk-7Jv" kind="relationship" relationship="window.shadowedContentViewController" id="Ht9-0G-qoI"/>
</connections>
</windowController>
<customObject id="Kmi-VL-W9X" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3" y="-412"/>
</scene>
<!--Command Line Install View Controller-->
<scene sceneID="AwT-mk-LEj">
<objects>
<viewController id="yq5-bk-7Jv" customClass="CommandLineInstallViewController" customModule="DevCleaner" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="pup-2Z-Mdm">
<rect key="frame" x="0.0" y="0.0" width="550" height="180"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xEt-zf-91o">
<rect key="frame" x="18" y="144" width="186" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Installing command line tool" id="4qU-hr-6XY">
<font key="font" metaFont="systemBold"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fYT-Ej-Qcq">
<rect key="frame" x="18" y="88" width="514" height="48"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" id="hwV-R4-kJl">
<font key="font" metaFont="system"/>
<string key="title">You can use DevCleaner from the command line. To make it easier, you can link command line tool script to one of your directories in PATH, for example /usr/local/bin.



</string>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="i8R-Zd-Gr0">
<rect key="frame" x="20" y="56" width="510" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" borderStyle="bezel" alignment="left" title="$ sudo ln -s /Applications/DevCleaner.app/Contents/Resources/dev-cleaner.sh /usr/local/bin/dev-cleaner" usesSingleLineMode="YES" bezelStyle="round" id="7Ur-jN-8pP">
<font key="font" size="12" name="Menlo-Regular"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="k9S-TW-6bi">
<rect key="frame" x="228" y="20" width="95" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="inline" title="Copy command" bezelStyle="inline" alignment="center" borderStyle="border" inset="2" id="dn0-jX-eaM">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" size="11" name=".SFNS-Semibold"/>
</buttonCell>
<connections>
<action selector="copyCommand:" target="yq5-bk-7Jv" id="TbM-74-uia"/>
</connections>
</button>
</subviews>
</view>
<connections>
<outlet property="commandTextField" destination="i8R-Zd-Gr0" id="FmE-3n-Mz4"/>
</connections>
</viewController>
<customObject id="IFY-B5-2js" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3" y="37"/>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// CommandLineInstallViewController.swift
// DevCleaner
//
// Created by Konrad Kołakowski on 06/03/2024.
// Copyright © 2024 One Minute Games. All rights reserved.
//
// DevCleaner is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// DevCleaner is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with DevCleaner. If not, see <http://www.gnu.org/licenses/>.

import Cocoa

final class CommandLineInstallViewController: NSViewController {
// MARK: Properties & outlets
@IBOutlet weak var commandTextField: NSTextField!

private var commandString: String {
let appPath = Bundle.main.bundlePath

return "sudo ln -s \(appPath)/Contents/Resources/dev-cleaner.sh /usr/local/bin/dev-cleaner"
}

// MARK: Initialization & overrides
override func viewDidLoad() {
super.viewDidLoad()

self.commandTextField.stringValue = "$ " + self.commandString
self.commandTextField.isSelectable = true
}

// MARK: Actions
@IBAction func copyCommand(_ sender: Any) {
let pasteboard = NSPasteboard.general
pasteboard.clearContents()

pasteboard.setString(self.commandString, forType: .string)
}
}
6 changes: 3 additions & 3 deletions DevCleaner/View Controllers/Help Window/Help.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="lcH-gJ-8Xh">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="lcH-gJ-8Xh">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15505"/>
<plugIn identifier="com.apple.WebKit2IBPlugin" version="15505"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
<plugIn identifier="com.apple.WebKit2IBPlugin" version="22505"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down
12 changes: 12 additions & 0 deletions DevCleaner/View Controllers/Help Window/HelpViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
// Created by Konrad Kołakowski on 07/09/2019.
// Copyright © 2019 One Minute Games. All rights reserved.
//
// DevCleaner is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// DevCleaner is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with DevCleaner. If not, see <http://www.gnu.org/licenses/>.

import Cocoa
import WebKit
Expand Down
Loading

0 comments on commit 035b7f4

Please sign in to comment.