From 3d33a2e6e6c9f9ac263714690840d39b124a6812 Mon Sep 17 00:00:00 2001 From: Jihoonahn Date: Fri, 1 Dec 2023 12:18:57 +0900 Subject: [PATCH] Add Tuist Support --- Sources/Command/Support/Tuist.swift | 116 ++++++++++++++++++++++++++-- 1 file changed, 108 insertions(+), 8 deletions(-) diff --git a/Sources/Command/Support/Tuist.swift b/Sources/Command/Support/Tuist.swift index 58666eb3..4be6e675 100644 --- a/Sources/Command/Support/Tuist.swift +++ b/Sources/Command/Support/Tuist.swift @@ -1,8 +1,108 @@ -// -// File.swift -// -// -// Created by Jihoonahn on 12/1/23. -// - -import Foundation +public struct Tuist { + @Command(\.bash) private var bash + + /// Build the project in the current directory + @discardableResult + public func build() -> Result { + return run("build") + } + + /// Build the project add Arguments + @discardableResult + public func build(_ arguments: [String]) -> Result { + let command = Arguments(["tuist", "build"] + arguments) + return bash.run(command) + } + + /// To clean all the data generated by Tuist + @discardableResult + public func clean(_ subset: String = "") -> Result { + return run("clean \(subset)") + } + + /// Dependencies can be fetched by running the following command + @discardableResult + public func fetch(_ options: String = "") -> Result { + return run("fetch \(options)") + } + + /// Editing your projects command + @discardableResult + public func edit(_ options: String = "") -> Result { + return run("edit \(options)") + } + + /// Running `tuist graph` Command + @discardableResult + public func graph() -> Result { + return run("graph") + } + + /// Running `tuist graph` Command with arguments + @discardableResult + public func graph(_ arguments: [String]) -> Result { + let command = Arguments(["tuist", "graph"] + arguments) + return bash.run(command) + } + + /// To generate the project in the current directory command + @discardableResult + public func generate() -> Result { + return run("generate") + } + + /// To generate the project in the current directory command with arguments + @discardableResult + public func generate(_ arguments: [String]) -> Result { + let command = Arguments(["tuist", "generate"] + arguments) + return bash.run(command) + } + + /// Running `tuist migration` command + @discardableResult + public func migration(_ arguments: [String]) -> Result { + let command = Arguments(["tuist", "migration"] + arguments) + return bash.run(command) + } + + /// Running `tuist scaffold` command + @discardableResult + public func scaffold(_ templateName: String, _ arguments: [String] = []) -> Result { + var command = ["tuist", "scaffold"] + command.append(templateName) + command += arguments + return bash.run(Arguments(command)) + } + + /// Test the project in the current directory + @discardableResult + public func test() -> Result { + return run("test") + } + + /// Test a specific scheme + @discardableResult + public func testScheme(_ schemeName: String) -> Result { + return run("test \(schemeName)") + } + + /// Test the project with arguments + @discardableResult + public func test(_ arguments: [String]) -> Result { + let command = Arguments(["tuist", "test"] + arguments) + return bash.run(command) + } + + /// Run Tuist using a given lane + @discardableResult + public func run(_ command: String) -> Result { + return bash.run("tuist \(command)") + } +} + +extension CommandValues { + /// Support Tuist Command + public var tuist: Tuist { + Tuist() + } +}