Skip to content

Commit

Permalink
Add Tuist Support
Browse files Browse the repository at this point in the history
  • Loading branch information
jihoonahn committed Dec 1, 2023
1 parent a9978b3 commit 3d33a2e
Showing 1 changed file with 108 additions and 8 deletions.
116 changes: 108 additions & 8 deletions Sources/Command/Support/Tuist.swift
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()
}
}

0 comments on commit 3d33a2e

Please sign in to comment.