@@ -5,9 +5,9 @@ public enum SystemCommand {}
55
66// This file contains a set of system commands that's used by Swiftly and its related tests and tooling
77
8- // Directory Service command line utility for macOS
9- // See dscl(1) for details
108extension SystemCommand {
9+ // Directory Service command line utility for macOS
10+ // See dscl(1) for details
1111 public static func dscl( executable: Executable = DsclCommand . defaultExecutable, datasource: String ? = nil ) -> DsclCommand {
1212 DsclCommand ( executable: executable, datasource: datasource)
1313 }
@@ -93,13 +93,15 @@ extension SystemCommand.DsclCommand.ReadCommand: Output {
9393 }
9494}
9595
96- // Create or operate on universal files
97- // See lipo(1) for details
9896extension SystemCommand {
97+ // Create or operate on universal files
98+ // See lipo(1) for details
9999 public static func lipo( executable: Executable = LipoCommand . defaultExecutable, inputFiles: FilePath ... ) -> LipoCommand {
100100 Self . lipo ( executable: executable, inputFiles: inputFiles)
101101 }
102102
103+ // Create or operate on universal files
104+ // See lipo(1) for details
103105 public static func lipo( executable: Executable = LipoCommand . defaultExecutable, inputFiles: [ FilePath ] ) -> LipoCommand {
104106 LipoCommand ( executable: executable, inputFiles: inputFiles)
105107 }
@@ -155,13 +157,15 @@ extension SystemCommand {
155157
156158extension SystemCommand . LipoCommand . CreateCommand : Runnable { }
157159
158- // Build a macOS Installer component package from on-disk files
159- // See pkgbuild(1) for more details
160160extension SystemCommand {
161+ // Build a macOS Installer component package from on-disk files
162+ // See pkgbuild(1) for more details
161163 public static func pkgbuild( executable: Executable = PkgbuildCommand . defaultExecutable, _ options: PkgbuildCommand . Option ... , root: FilePath , packageOutputPath: FilePath ) -> PkgbuildCommand {
162164 Self . pkgbuild ( executable: executable, options: options, root: root, packageOutputPath: packageOutputPath)
163165 }
164166
167+ // Build a macOS Installer component package from on-disk files
168+ // See pkgbuild(1) for more details
165169 public static func pkgbuild( executable: Executable = PkgbuildCommand . defaultExecutable, options: [ PkgbuildCommand . Option ] , root: FilePath , packageOutputPath: FilePath ) -> PkgbuildCommand {
166170 PkgbuildCommand ( executable: executable, options, root: root, packageOutputPath: packageOutputPath)
167171 }
@@ -224,13 +228,15 @@ extension SystemCommand {
224228
225229extension SystemCommand . PkgbuildCommand : Runnable { }
226230
227- // get entries from Name Service Switch libraries
228- // See getent(1) for more details
229231extension SystemCommand {
232+ // get entries from Name Service Switch libraries
233+ // See getent(1) for more details
230234 public static func getent( executable: Executable = GetentCommand . defaultExecutable, database: String , keys: String ... ) -> GetentCommand {
231235 Self . getent ( executable: executable, database: database, keys: keys)
232236 }
233237
238+ // get entries from Name Service Switch libraries
239+ // See getent(1) for more details
234240 public static func getent( executable: Executable = GetentCommand . defaultExecutable, database: String , keys: [ String ] ) -> GetentCommand {
235241 GetentCommand ( executable: executable, database: database, keys: keys)
236242 }
@@ -283,6 +289,8 @@ extension SystemCommand.GetentCommand: Output {
283289}
284290
285291extension SystemCommand {
292+ // the stupid content tracker
293+ // See git(1) for more information.
286294 public static func git( executable: Executable = GitCommand . defaultExecutable, workingDir: FilePath ? = nil ) -> GitCommand {
287295 GitCommand ( executable: executable, workingDir: workingDir)
288296 }
@@ -486,13 +494,15 @@ extension SystemCommand.GitCommand.DiffIndexCommand: Runnable {}
486494extension SystemCommand . GitCommand . InitCommand : Runnable { }
487495extension SystemCommand . GitCommand . CommitCommand : Runnable { }
488496
489- // manipulate tape archives
490- // See tar(1) for more details
491497extension SystemCommand {
498+ // manipulate tape archives
499+ // See tar(1) for more details
492500 public static func tar( executable: Executable = TarCommand . defaultExecutable, _ options: TarCommand . Option ... ) -> TarCommand {
493501 Self . tar ( executable: executable, options)
494502 }
495503
504+ // manipulate tape archives
505+ // See tar(1) for more details
496506 public static func tar( executable: Executable = TarCommand . defaultExecutable, _ options: [ TarCommand . Option ] ) -> TarCommand {
497507 TarCommand ( executable: executable, options)
498508 }
@@ -948,6 +958,8 @@ extension SystemCommand.SwiftCommand.SdkCommand.RemoveCommand: Runnable {}
948958extension SystemCommand . SwiftCommand . BuildCommand : Runnable { }
949959
950960extension SystemCommand {
961+ // make utility to maintain groups of programs
962+ // See make(1) for more information.
951963 public static func make( executable: Executable = MakeCommand . defaultExecutable) -> MakeCommand {
952964 MakeCommand ( executable: executable)
953965 }
@@ -1001,10 +1013,14 @@ extension SystemCommand.MakeCommand: Runnable {}
10011013extension SystemCommand . MakeCommand . InstallCommand : Runnable { }
10021014
10031015extension SystemCommand {
1016+ // remove symbols
1017+ // See strip(1) for more information.
10041018 public static func strip( executable: Executable = StripCommand . defaultExecutable, names: FilePath ... ) -> StripCommand {
10051019 self . strip ( executable: executable, names: names)
10061020 }
10071021
1022+ // remove symbols
1023+ // See strip(1) for more information.
10081024 public static func strip( executable: Executable = StripCommand . defaultExecutable, names: [ FilePath ] ) -> StripCommand {
10091025 StripCommand ( executable: executable, names: names)
10101026 }
@@ -1038,10 +1054,14 @@ extension SystemCommand {
10381054extension SystemCommand . StripCommand : Runnable { }
10391055
10401056extension SystemCommand {
1057+ // calculate a message-digest fingerprint (checksum) for a file
1058+ // See sha256sum(1) for more information.
10411059 public static func sha256sum( executable: Executable = Sha256SumCommand . defaultExecutable, files: FilePath ... ) -> Sha256SumCommand {
10421060 self . sha256sum ( executable: executable, files: files)
10431061 }
10441062
1063+ // calculate a message-digest fingerprint (checksum) for a file
1064+ // See sha256sum(1) for more information.
10451065 public static func sha256sum( executable: Executable , files: [ FilePath ] ) -> Sha256SumCommand {
10461066 Sha256SumCommand ( executable: executable, files: files)
10471067 }
@@ -1073,3 +1093,126 @@ extension SystemCommand {
10731093}
10741094
10751095extension SystemCommand . Sha256SumCommand : Output { }
1096+
1097+ extension SystemCommand {
1098+ // Build a product archive for the macOS Installer or the Mac App Store.
1099+ // See productbuild(1) for more information.
1100+ public static func productbuild( executable: Executable = ProductBuildCommand . defaultExecutable) -> ProductBuildCommand {
1101+ ProductBuildCommand ( executable: executable)
1102+ }
1103+
1104+ public struct ProductBuildCommand {
1105+ public static var defaultExecutable : Executable { . name( " productbuild " ) }
1106+
1107+ public var executable : Executable
1108+
1109+ public init ( executable: Executable ) {
1110+ self . executable = executable
1111+ }
1112+
1113+ public func config( ) -> Configuration {
1114+ var args : [ String ] = [ ]
1115+
1116+ return Configuration (
1117+ executable: self . executable,
1118+ arguments: Arguments ( args) ,
1119+ environment: . inherit
1120+ )
1121+ }
1122+
1123+ public func synthesize( package : FilePath , distributionOutputPath: FilePath ) -> SynthesizeCommand {
1124+ SynthesizeCommand ( self , package : package , distributionOutputPath: distributionOutputPath)
1125+ }
1126+
1127+ public struct SynthesizeCommand {
1128+ public var productBuildCommand : ProductBuildCommand
1129+
1130+ public var package : FilePath
1131+
1132+ public var distributionOutputPath : FilePath
1133+
1134+ public init ( _ productBuildCommand: ProductBuildCommand , package : FilePath , distributionOutputPath: FilePath ) {
1135+ self . productBuildCommand = productBuildCommand
1136+ self . package = package
1137+ self . distributionOutputPath = distributionOutputPath
1138+ }
1139+
1140+ public func config( ) -> Configuration {
1141+ var c = self . productBuildCommand. config ( )
1142+
1143+ var args = c. arguments. storage. map ( \. description)
1144+
1145+ args. append ( " --synthesize " )
1146+
1147+ args. append ( contentsOf: [ " --package " , " \( self . package ) " ] )
1148+ args. append ( " \( self . distributionOutputPath) " )
1149+
1150+ c. arguments = . init( args)
1151+
1152+ return c
1153+ }
1154+ }
1155+
1156+ public func distribution( _ options: DistributionCommand . Option ... , distPath: FilePath , productOutputPath: FilePath ) -> DistributionCommand {
1157+ self . distribution ( options, distPath: distPath, productOutputPath: productOutputPath)
1158+ }
1159+
1160+ public func distribution( _ options: [ DistributionCommand . Option ] , distPath: FilePath , productOutputPath: FilePath ) -> DistributionCommand {
1161+ DistributionCommand ( self , options, distPath: distPath, productOutputPath: productOutputPath)
1162+ }
1163+
1164+ public struct DistributionCommand {
1165+ public var productBuildCommand : ProductBuildCommand
1166+
1167+ public var options : [ Option ]
1168+
1169+ public var distPath : FilePath
1170+
1171+ public var productOutputPath : FilePath
1172+
1173+ public enum Option {
1174+ case packagePath( FilePath )
1175+ case sign( String )
1176+
1177+ public func args( ) -> [ String ] {
1178+ switch self {
1179+ case let . packagePath( packagePath) :
1180+ [ " --package-path " , " \( packagePath) " ]
1181+ case let . sign( sign) :
1182+ [ " --sign " , " \( sign) " ]
1183+ }
1184+ }
1185+ }
1186+
1187+ public init ( _ productBuildCommand: ProductBuildCommand , _ options: [ Option ] , distPath: FilePath , productOutputPath: FilePath ) {
1188+ self . productBuildCommand = productBuildCommand
1189+ self . options = options
1190+ self . distPath = distPath
1191+ self . productOutputPath = productOutputPath
1192+ }
1193+
1194+ public func config( ) -> Configuration {
1195+ var c = self . productBuildCommand. config ( )
1196+
1197+ var args = c. arguments. storage. map ( \. description)
1198+
1199+ args. append ( " --distribution " )
1200+
1201+ args. append ( " \( self . distPath) " )
1202+
1203+ for opt in self . options {
1204+ args. append ( contentsOf: opt. args ( ) )
1205+ }
1206+
1207+ args. append ( " \( self . productOutputPath) " )
1208+
1209+ c. arguments = . init( args)
1210+
1211+ return c
1212+ }
1213+ }
1214+ }
1215+ }
1216+
1217+ extension SystemCommand . ProductBuildCommand . SynthesizeCommand : Runnable { }
1218+ extension SystemCommand . ProductBuildCommand . DistributionCommand : Runnable { }
0 commit comments