53 lines
1.3 KiB
Swift
53 lines
1.3 KiB
Swift
import ArgumentParser
|
|
import CliDoc
|
|
import CommandClient
|
|
import Dependencies
|
|
|
|
struct InstallDependenciesCommand: AsyncParsableCommand {
|
|
static let commandName: String = "install-dependencies"
|
|
|
|
static let configuration = CommandConfiguration(
|
|
commandName: commandName,
|
|
abstract: createAbstract("Ensure required dependencies are installed"),
|
|
usage: .default(commandName: commandName, parentCommand: "utils", usesArguments: false),
|
|
discussion: Discussion {
|
|
VStack {
|
|
Note {
|
|
"Homebrew is required to install dependencies."
|
|
}
|
|
HStack {
|
|
"See Also:".yellow.bold.underline
|
|
"https://brew.sh"
|
|
}
|
|
ImportantNote.passingExtraArgs
|
|
}
|
|
.separator(.newLine(count: 2))
|
|
}
|
|
)
|
|
|
|
@OptionGroup var globals: BasicGlobalOptions
|
|
|
|
@Argument(
|
|
help: "Extra arguments / options to pass to the homebrew command."
|
|
)
|
|
var extraOptions: [String] = []
|
|
|
|
mutating func run() async throws {
|
|
@Dependency(\.commandClient) var commandClient
|
|
@Dependency(\.playbookClient) var playbookClient
|
|
|
|
let arguments = [
|
|
"brew", "install"
|
|
] + Constants.brewPackages
|
|
+ extraOptions
|
|
|
|
try await commandClient.run(
|
|
quiet: globals.quiet,
|
|
shell: globals.shell,
|
|
arguments
|
|
)
|
|
|
|
try await playbookClient.repository.install()
|
|
}
|
|
}
|