@@ -13,14 +13,15 @@ struct Plist2Profile: ParsableCommand {
13
13
static var configuration = CommandConfiguration (
14
14
commandName: " plist2profile " ,
15
15
abstract: " converts a standard preference plist file to a mobileconfig profile " ,
16
- usage: " plist2profile <identifier> <plist> ... " ,
16
+ usage: " plist2profile --identifier <identifier> <plist> ... " ,
17
17
version: " 0.1 "
18
18
)
19
-
19
+
20
20
// MARK: arguments,options, flags
21
- @Argument (
21
+ @Option (
22
+ name: . shortAndLong,
22
23
help: ArgumentHelp (
23
- " the payload identifier for the profile " ,
24
+ " the identifier for the profile " ,
24
25
valueName: " identifier "
25
26
)
26
27
)
@@ -52,14 +53,20 @@ struct Plist2Profile: ParsableCommand {
52
53
)
53
54
var displayName = " "
54
55
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
+
55
62
// TODO: option to create a modern or mcx profile
56
63
57
64
// MARK: variables
58
65
59
66
var uuid = UUID ( )
60
67
var payloadVersion = 1
61
68
var payloadType = " Configuration "
62
- var payloadScope = " System " // or "User"
69
+ var payloadScope = " System "
63
70
64
71
// TODO: missing keys for profile
65
72
// removal disallowed
@@ -100,7 +107,11 @@ struct Plist2Profile: ParsableCommand {
100
107
101
108
// if output is empty, generate file name
102
109
if outputPath. isEmpty {
103
- outputPath = identifier. appending ( " .plist " )
110
+ outputPath = identifier. appending ( " .mobileConfig " )
111
+ }
112
+
113
+ if userScope {
114
+ payloadScope = " User "
104
115
}
105
116
}
106
117
@@ -164,9 +175,11 @@ struct Plist2Profile: ParsableCommand {
164
175
// insert payloads array
165
176
profileDict [ " PayloadContent " ] = payloads
166
177
167
- let profileURL = URL ( filePath: identifier)
168
- . appendingPathExtension ( " mobileconfig " )
178
+ let profileURL = URL ( filePath: outputPath)
169
179
try profileDict. write ( to: profileURL)
180
+
181
+ // TODO: sign profile after creation
182
+
170
183
print ( profileURL. relativePath)
171
184
}
172
185
}
0 commit comments