Skip to content

Commit bdf7244

Browse files
committedMar 21, 2024
added '--user' flag, fixed some other options
1 parent 3a6eae5 commit bdf7244

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed
 

‎.swiftpm/xcode/xcshareddata/xcschemes/plist2profile.xcscheme

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353
<CommandLineArguments>
5454
<CommandLineArgument
5555
argument = "com.scriptingosx.example"
56-
isEnabled = "YES">
56+
isEnabled = "NO">
5757
</CommandLineArgument>
5858
<CommandLineArgument
5959
argument = "/Users/armin/BTSync/Work/Projects/setup-manager-private/Setup\ Manager/Documentation/sample-com.jamf.setupmanager.plist"
60-
isEnabled = "YES">
60+
isEnabled = "NO">
6161
</CommandLineArgument>
6262
</CommandLineArguments>
6363
</LaunchAction>

‎Sources/plist2profile/Plist2Profile.swift

+21-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ struct Plist2Profile: ParsableCommand {
1313
static var configuration = CommandConfiguration(
1414
commandName: "plist2profile",
1515
abstract: "converts a standard preference plist file to a mobileconfig profile",
16-
usage: "plist2profile <identifier> <plist> ...",
16+
usage: "plist2profile --identifier <identifier> <plist> ...",
1717
version: "0.1"
1818
)
19-
19+
2020
// MARK: arguments,options, flags
21-
@Argument(
21+
@Option(
22+
name: .shortAndLong,
2223
help: ArgumentHelp(
23-
"the payload identifier for the profile",
24+
"the identifier for the profile",
2425
valueName: "identifier"
2526
)
2627
)
@@ -52,14 +53,20 @@ struct Plist2Profile: ParsableCommand {
5253
)
5354
var displayName = ""
5455

56+
@Flag(
57+
name: .customLong("user"),
58+
help: "sets the scope for the profile to 'User' (otherwise scope is 'System')"
59+
)
60+
var userScope = false
61+
5562
// TODO: option to create a modern or mcx profile
5663

5764
// MARK: variables
5865

5966
var uuid = UUID()
6067
var payloadVersion = 1
6168
var payloadType = "Configuration"
62-
var payloadScope = "System" // or "User"
69+
var payloadScope = "System"
6370

6471
// TODO: missing keys for profile
6572
// removal disallowed
@@ -100,7 +107,11 @@ struct Plist2Profile: ParsableCommand {
100107

101108
// if output is empty, generate file name
102109
if outputPath.isEmpty {
103-
outputPath = identifier.appending(".plist")
110+
outputPath = identifier.appending(".mobileConfig")
111+
}
112+
113+
if userScope {
114+
payloadScope = "User"
104115
}
105116
}
106117

@@ -164,9 +175,11 @@ struct Plist2Profile: ParsableCommand {
164175
// insert payloads array
165176
profileDict["PayloadContent"] = payloads
166177

167-
let profileURL = URL(filePath: identifier)
168-
.appendingPathExtension("mobileconfig")
178+
let profileURL = URL(filePath: outputPath)
169179
try profileDict.write(to: profileURL)
180+
181+
// TODO: sign profile after creation
182+
170183
print(profileURL.relativePath)
171184
}
172185
}

0 commit comments

Comments
 (0)
Please sign in to comment.