Skip to content

Commit 96d68e7

Browse files
committed
Add (re)create to autocreate manager and cli args
1 parent be89db7 commit 96d68e7

File tree

5 files changed

+96
-31
lines changed

5 files changed

+96
-31
lines changed

TmpDisk.xcodeproj/project.pbxproj

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
220082562765505100A8524B /* TmpDiskTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220082552765505100A8524B /* TmpDiskTests.swift */; };
1414
220082602765505100A8524B /* TmpDiskUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2200825F2765505100A8524B /* TmpDiskUITests.swift */; };
1515
220082622765505100A8524B /* TmpDiskUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220082612765505100A8524B /* TmpDiskUITestsLaunchTests.swift */; };
16+
22235EC027784F8200FBD8AC /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 22235EBF27784F8200FBD8AC /* dsa_pub.pem */; };
1617
2264C5E2276553E600C45CB8 /* StatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2264C5E1276553E600C45CB8 /* StatusBarController.swift */; };
1718
2264C5E62765667500C45CB8 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2264C5E82765667500C45CB8 /* Localizable.strings */; };
1819
2264C5EC27657AAC00C45CB8 /* TmpDiskManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2264C5EB27657AAC00C45CB8 /* TmpDiskManager.swift */; };
@@ -71,6 +72,7 @@
7172
2200825F2765505100A8524B /* TmpDiskUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TmpDiskUITests.swift; sourceTree = "<group>"; };
7273
220082612765505100A8524B /* TmpDiskUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TmpDiskUITestsLaunchTests.swift; sourceTree = "<group>"; };
7374
2200826E2765508C00A8524B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
75+
22235EBF27784F8200FBD8AC /* dsa_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dsa_pub.pem; sourceTree = "<group>"; };
7476
2264C5E1276553E600C45CB8 /* StatusBarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; };
7577
2264C5E72765667500C45CB8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
7678
2264C5E92765667700C45CB8 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
@@ -155,6 +157,7 @@
155157
2264C5E1276553E600C45CB8 /* StatusBarController.swift */,
156158
2264C5EB27657AAC00C45CB8 /* TmpDiskManager.swift */,
157159
220082472765505100A8524B /* Assets.xcassets */,
160+
22235EBF27784F8200FBD8AC /* dsa_pub.pem */,
158161
2200826E2765508C00A8524B /* Info.plist */,
159162
220082492765505100A8524B /* Main.storyboard */,
160163
2200824C2765505100A8524B /* TmpDisk.entitlements */,
@@ -346,6 +349,7 @@
346349
buildActionMask = 2147483647;
347350
files = (
348351
220082482765505100A8524B /* Assets.xcassets in Resources */,
352+
22235EC027784F8200FBD8AC /* dsa_pub.pem in Resources */,
349353
2264C5E62765667500C45CB8 /* Localizable.strings in Resources */,
350354
2200824B2765505100A8524B /* Main.storyboard in Resources */,
351355
);
@@ -588,7 +592,7 @@
588592
CODE_SIGN_IDENTITY = "Apple Development";
589593
CODE_SIGN_STYLE = Automatic;
590594
COMBINE_HIDPI_IMAGES = YES;
591-
CURRENT_PROJECT_VERSION = 1;
595+
CURRENT_PROJECT_VERSION = 1001;
592596
DEVELOPMENT_TEAM = AGZ3AP53DM;
593597
ENABLE_HARDENED_RUNTIME = YES;
594598
GENERATE_INFOPLIST_FILE = YES;
@@ -602,7 +606,7 @@
602606
"@executable_path/../Frameworks",
603607
);
604608
MACOSX_DEPLOYMENT_TARGET = 10.11;
605-
MARKETING_VERSION = 2.0.0;
609+
MARKETING_VERSION = 2.0.1;
606610
PRODUCT_BUNDLE_IDENTIFIER = com.imothee.TmpDisk;
607611
PRODUCT_NAME = "$(TARGET_NAME)";
608612
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -619,7 +623,7 @@
619623
CODE_SIGN_IDENTITY = "Apple Development";
620624
CODE_SIGN_STYLE = Automatic;
621625
COMBINE_HIDPI_IMAGES = YES;
622-
CURRENT_PROJECT_VERSION = 1;
626+
CURRENT_PROJECT_VERSION = 1001;
623627
DEVELOPMENT_TEAM = AGZ3AP53DM;
624628
ENABLE_HARDENED_RUNTIME = YES;
625629
GENERATE_INFOPLIST_FILE = YES;
@@ -633,7 +637,7 @@
633637
"@executable_path/../Frameworks",
634638
);
635639
MACOSX_DEPLOYMENT_TARGET = 10.11;
636-
MARKETING_VERSION = 2.0.0;
640+
MARKETING_VERSION = 2.0.1;
637641
PRODUCT_BUNDLE_IDENTIFIER = com.imothee.TmpDisk;
638642
PRODUCT_NAME = "$(TARGET_NAME)";
639643
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -745,20 +749,21 @@
745749
CODE_SIGN_ENTITLEMENTS = TmpDiskLauncher/TmpDiskLauncher.entitlements;
746750
CODE_SIGN_STYLE = Automatic;
747751
COMBINE_HIDPI_IMAGES = YES;
748-
CURRENT_PROJECT_VERSION = 1;
752+
CURRENT_PROJECT_VERSION = 2;
749753
DEVELOPMENT_TEAM = AGZ3AP53DM;
750754
ENABLE_HARDENED_RUNTIME = YES;
751755
GENERATE_INFOPLIST_FILE = YES;
752756
INFOPLIST_FILE = TmpDiskLauncher/Info.plist;
757+
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
753758
INFOPLIST_KEY_NSHumanReadableCopyright = "";
754759
INFOPLIST_KEY_NSMainStoryboardFile = Main;
755760
INFOPLIST_KEY_NSPrincipalClass = NSApplication;
756761
LD_RUNPATH_SEARCH_PATHS = (
757762
"$(inherited)",
758763
"@executable_path/../Frameworks",
759764
);
760-
MACOSX_DEPLOYMENT_TARGET = 12.1;
761-
MARKETING_VERSION = 2.0;
765+
MACOSX_DEPLOYMENT_TARGET = 10.11;
766+
MARKETING_VERSION = 2.0.1;
762767
PRODUCT_BUNDLE_IDENTIFIER = com.imothee.TmpDiskLauncher;
763768
PRODUCT_NAME = "$(TARGET_NAME)";
764769
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -774,20 +779,21 @@
774779
CODE_SIGN_ENTITLEMENTS = TmpDiskLauncher/TmpDiskLauncher.entitlements;
775780
CODE_SIGN_STYLE = Automatic;
776781
COMBINE_HIDPI_IMAGES = YES;
777-
CURRENT_PROJECT_VERSION = 1;
782+
CURRENT_PROJECT_VERSION = 2;
778783
DEVELOPMENT_TEAM = AGZ3AP53DM;
779784
ENABLE_HARDENED_RUNTIME = YES;
780785
GENERATE_INFOPLIST_FILE = YES;
781786
INFOPLIST_FILE = TmpDiskLauncher/Info.plist;
787+
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
782788
INFOPLIST_KEY_NSHumanReadableCopyright = "";
783789
INFOPLIST_KEY_NSMainStoryboardFile = Main;
784790
INFOPLIST_KEY_NSPrincipalClass = NSApplication;
785791
LD_RUNPATH_SEARCH_PATHS = (
786792
"$(inherited)",
787793
"@executable_path/../Frameworks",
788794
);
789-
MACOSX_DEPLOYMENT_TARGET = 12.1;
790-
MARKETING_VERSION = 2.0;
795+
MACOSX_DEPLOYMENT_TARGET = 10.11;
796+
MARKETING_VERSION = 2.0.1;
791797
PRODUCT_BUNDLE_IDENTIFIER = com.imothee.TmpDiskLauncher;
792798
PRODUCT_NAME = "$(TARGET_NAME)";
793799
SWIFT_EMIT_LOC_STRINGS = YES;

TmpDisk/AppDelegate.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
3636
func applicationDidFinishLaunching(_ aNotification: Notification) {
3737
statusBar = StatusBarController.init()
3838

39+
// Check if TmpDisk was loaded with command line args
40+
let (name, size) = getArgs()
41+
if let name = name, let size = size {
42+
let volume = TmpDiskVolume(name: name, size: size)
43+
TmpDiskManager.shared.createTmpDisk(volume: volume, onCreate: {_ in})
44+
}
45+
3946
NotificationCenter.default.addObserver(forName: .tmpDiskMounted, object: nil, queue: .main) { notification in
4047
self.statusBar?.buildCurrentTmpDiskMenu()
4148
}
@@ -65,5 +72,29 @@ class AppDelegate: NSObject, NSApplicationDelegate {
6572
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
6673
return true
6774
}
75+
76+
// We expect args in the format -argname=argval
77+
private func getArgs() -> (String?, Int?) {
78+
let args = ProcessInfo.processInfo.arguments
79+
var name: String?
80+
var size: Int?
81+
82+
for arg in args {
83+
let values = arg.components(separatedBy: "=")
84+
if values.count == 2 {
85+
switch values[0] {
86+
case "-name":
87+
name = values[1]
88+
break
89+
case "-size":
90+
size = (values[1] as NSString).integerValue
91+
break
92+
default:
93+
break
94+
}
95+
}
96+
}
97+
return (name, size)
98+
}
6899
}
69100

0 commit comments

Comments
 (0)