-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
108 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |