@@ -32,22 +32,28 @@ enum ZeroValidationError: LocalizedError {
3232struct ZeroRunner {
3333 let configDirectory : Path
3434 let workspace : Workspace
35+ let verbose : Bool
3536
36- init ( configDirectory: Path ? = nil , workspace: Workspace ) throws {
37+ init ( configDirectory: Path ? = nil , workspace: Workspace , verbose : Bool ) throws {
3738 let fallbackDirectories : [ Path ] = [
3839 Path . XDG. configHome. join ( " zero " ) . join ( " dotfiles " ) ,
3940 Path . home. join ( " .dotfiles " ) ,
4041 ]
4142 self . configDirectory = configDirectory ?? fallbackDirectories. first { $0. isDirectory } ??
4243 fallbackDirectories. last!
44+ self . verbose = verbose
4345 self . workspace = workspace
4446 try validate ( )
4547 }
4648
4749 /// Run an executable with the given arguments, printing the command before
4850 /// running.
49- func runTask( _ executable: String , _ arguments: String ... , at directory: Path ? = nil ) throws {
50- printCommand ( executable, arguments)
51+ static func runTask(
52+ _ executable: String ,
53+ arguments: [ String ] ,
54+ at directory: Path ? = nil
55+ ) throws {
56+ self . printCommand ( executable, arguments)
5157
5258 if let directory = directory, executable. hasPrefix ( " . " ) {
5359 // Process.launchPath doesn't seem to honor currentDirectoryPath
@@ -64,8 +70,12 @@ struct ZeroRunner {
6470
6571 /// Run an executable using `Task.spawn` with the given arguments, printing
6672 /// the command before running.
67- func spawnTask( _ executable: String , _ arguments: String ... , at directory: Path ? = nil ) throws {
68- printCommand ( executable, arguments)
73+ static func spawnTask(
74+ _ executable: String ,
75+ arguments: [ String ] ,
76+ at directory: Path ? = nil
77+ ) throws {
78+ self . printCommand ( executable, arguments)
6979
7080 let fileManager = FileManager . default
7181 let previousWorkingDirectory = fileManager. currentDirectoryPath
@@ -86,6 +96,22 @@ struct ZeroRunner {
8696 throw SpawnError ( exitStatus: exitStatus)
8797 }
8898 }
99+
100+ static func runTask(
101+ _ executable: String ,
102+ _ arguments: String ... ,
103+ at directory: Path ? = nil
104+ ) throws {
105+ try self . runTask ( executable, arguments: arguments, at: directory)
106+ }
107+
108+ static func spawnTask(
109+ _ executable: String ,
110+ _ arguments: String ... ,
111+ at directory: Path ? = nil
112+ ) throws {
113+ try self . spawnTask ( executable, arguments: arguments, at: directory)
114+ }
89115}
90116
91117private extension ZeroRunner {
@@ -117,7 +143,7 @@ private extension ZeroRunner {
117143 }
118144 }
119145
120- func printCommand( _ executable: String , _ arguments: [ String ] ) {
146+ static func printCommand( _ executable: String , _ arguments: [ String ] ) {
121147 let escapedCommand : [ String ] = [ executable] + arguments. map ( Task . escapeArgument)
122148 Term . stdout <<< TTY . commandMessage ( escapedCommand. joined ( separator: " " ) )
123149 }
0 commit comments