2 Commits

7 changed files with 60 additions and 8 deletions

View File

@@ -40,6 +40,9 @@ let package = Package(
.product(name: "Dependencies", package: "swift-dependencies"),
.product(name: "DependenciesMacros", package: "swift-dependencies"),
.product(name: "ShellClient", package: "swift-shell-client")
],
resources: [
.copy("Resources/Brewfile")
]
),
.testTarget(

View File

@@ -23,6 +23,21 @@ public extension CliClient {
try await runCommand(quiet: quiet, shell: shell, args)
}
func installDependencies(
quiet: Bool = false,
shell: String? = nil
) async throws {
guard let url = Bundle.module.url(forResource: "Brewfile", withExtension: nil) else {
throw CliClientError.brewfileNotFound
}
try await runCommand(
quiet: quiet,
shell: shell.orDefault,
"brew", "bundle",
"--file", url.cleanFilePath
)
}
func runPlaybookCommand(
_ options: PlaybookOptions,
logging loggingOptions: LoggingOptions

View File

@@ -1,6 +1,7 @@
import Foundation
public enum CliClientError: Error {
case brewfileNotFound
case encodingError
case playbookDirectoryNotFound
case templateDirectoryNotFound

View File

@@ -0,0 +1,4 @@
brew "ansible"
brew "imagemagick"
brew "pandoc"
brew "texlive"

View File

@@ -0,0 +1,35 @@
import ArgumentParser
import CliClient
import CliDoc
import Dependencies
struct InstallDependenciesCommand: AsyncParsableCommand {
static let commandName: String = "install-dependencies"
static let configuration = CommandConfiguration(
commandName: commandName,
abstract: createAbstract("Ensure required dependencies are installed"),
discussion: Discussion {
VStack {
Note {
"Homebrew is required to install dependencies."
}
HStack {
"See Also:".yellow.bold.underline
"https://brew.sh"
}
}
.separator(.newLine(count: 2))
}
)
@OptionGroup var globals: BasicGlobalOptions
mutating func run() async throws {
@Dependency(\.cliClient) var cliClient
try await cliClient.installDependencies(
quiet: globals.quiet,
shell: globals.shell
)
}
}

View File

@@ -11,7 +11,8 @@ struct UtilsCommand: AsyncParsableCommand {
""",
subcommands: [
GenerateProjectTemplateCommand.self,
GenerateConfigurationCommand.self
GenerateConfigurationCommand.self,
InstallDependenciesCommand.self
]
)

View File

@@ -19,7 +19,6 @@ struct DecryptCommand: AsyncParsableCommand {
)
var output: String?
// FIX:
mutating func run() async throws {
@Dependency(\.cliClient) var cliClient
@@ -32,11 +31,5 @@ struct DecryptCommand: AsyncParsableCommand {
options.vaultOptions(arguments: args, configuration: nil),
logging: options.loggingOptions(commandName: Self.commandName)
)
// try await runVault(
// commandName: Self.commandName,
// options: options,
// args
// )
}
}