@@ -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