feat: Updates 'extraArgs' naming to 'extraOptions' as it's more inline with the usage of them

This commit is contained in:
2024-12-12 18:21:13 -05:00
parent bd56660683
commit ba1e61d99e
7 changed files with 43 additions and 22 deletions

View File

@@ -25,16 +25,24 @@ public extension CliClient {
func installDependencies( func installDependencies(
quiet: Bool = false, quiet: Bool = false,
shell: String? = nil shell: String? = nil,
extraArgs: [String]? = nil
) async throws { ) async throws {
guard let url = Bundle.module.url(forResource: "Brewfile", withExtension: nil) else { guard let url = Bundle.module.url(forResource: "Brewfile", withExtension: nil) else {
throw CliClientError.brewfileNotFound throw CliClientError.brewfileNotFound
} }
var arguments = [
"brew", "bundle",
"--file", url.cleanFilePath
]
if let extraArgs {
arguments.append(contentsOf: extraArgs)
}
try await runCommand( try await runCommand(
quiet: quiet, quiet: quiet,
shell: shell.orDefault, shell: shell.orDefault,
"brew", "bundle", arguments
"--file", url.cleanFilePath
) )
} }

View File

@@ -21,9 +21,9 @@ struct BuildCommand: AsyncParsableCommand {
var projectDir: String var projectDir: String
@Argument( @Argument(
help: "Extra arguments passed to the playbook." help: "Extra arguments / options passed to the playbook."
) )
var extraArgs: [String] = [] var extraOptions: [String] = []
mutating func run() async throws { mutating func run() async throws {
try await _run() try await _run()

View File

@@ -54,7 +54,7 @@ struct CreateCommand: AsyncParsableCommand {
@Argument( @Argument(
help: "Extra arguments passed to the playbook." help: "Extra arguments passed to the playbook."
) )
var extraArgs: [String] = [] var extraOptions: [String] = []
mutating func run() async throws { mutating func run() async throws {
try await _run() try await _run()
@@ -81,7 +81,7 @@ struct CreateCommand: AsyncParsableCommand {
"--tags", "setup-project", "--tags", "setup-project",
"--extra-vars", "project_dir=\(self.projectDir)", "--extra-vars", "project_dir=\(self.projectDir)",
"--extra-vars", "'\(json)'" "--extra-vars", "'\(json)'"
] + extraArgs ] + extraOptions
try await cliClient.runPlaybookCommand( try await cliClient.runPlaybookCommand(
globals.playbookOptions( globals.playbookOptions(

View File

@@ -25,7 +25,13 @@ func createAbstract(_ string: String) -> String {
extension Usage where Content == AnyTextNode { extension Usage where Content == AnyTextNode {
static func `default`(commandName: String, parentCommand: String?) -> Self { static func `default`(
commandName: String,
parentCommand: String?,
usesArguments: Bool = true,
usesOptions: Bool = true,
usesExtraArguments: Bool = true
) -> Self {
.init { .init {
HStack { HStack {
HStack { HStack {
@@ -37,10 +43,16 @@ extension Usage where Content == AnyTextNode {
} }
.color(.blue).bold() .color(.blue).bold()
"[OPTIONS]".color(.green) if usesOptions {
"[ARGUMENTS]".color(.cyan) "[OPTIONS]".color(.green)
"--" }
"[EXTRA-OPTIONS]".color(.magenta) if usesArguments {
"[ARGUMENTS]".color(.cyan)
}
if usesExtraArguments {
"--"
"[EXTRA-OPTIONS]".color(.magenta)
}
} }
.eraseToAnyTextNode() .eraseToAnyTextNode()

View File

@@ -34,9 +34,9 @@ struct GenerateProjectTemplateCommand: AsyncParsableCommand {
var path: String var path: String
@Argument( @Argument(
help: "Extra arguments passed to the playbook." help: "Extra arguments / options passed to the playbook."
) )
var extraArgs: [String] = [] var extraOptions: [String] = []
mutating func run() async throws { mutating func run() async throws {
@Dependency(\.cliClient) var cliClient @Dependency(\.cliClient) var cliClient

View File

@@ -9,6 +9,7 @@ struct InstallDependenciesCommand: AsyncParsableCommand {
static let configuration = CommandConfiguration( static let configuration = CommandConfiguration(
commandName: commandName, commandName: commandName,
abstract: createAbstract("Ensure required dependencies are installed"), abstract: createAbstract("Ensure required dependencies are installed"),
usage: .default(commandName: commandName, parentCommand: "utils", usesArguments: false),
discussion: Discussion { discussion: Discussion {
VStack { VStack {
Note { Note {
@@ -18,6 +19,7 @@ struct InstallDependenciesCommand: AsyncParsableCommand {
"See Also:".yellow.bold.underline "See Also:".yellow.bold.underline
"https://brew.sh" "https://brew.sh"
} }
ImportantNote.passingExtraArgs
} }
.separator(.newLine(count: 2)) .separator(.newLine(count: 2))
} }
@@ -25,11 +27,17 @@ struct InstallDependenciesCommand: AsyncParsableCommand {
@OptionGroup var globals: BasicGlobalOptions @OptionGroup var globals: BasicGlobalOptions
@Argument(
help: "Extra arguments / options to pass to the homebrew command."
)
var extraOptions: [String]
mutating func run() async throws { mutating func run() async throws {
@Dependency(\.cliClient) var cliClient @Dependency(\.cliClient) var cliClient
try await cliClient.installDependencies( try await cliClient.installDependencies(
quiet: globals.quiet, quiet: globals.quiet,
shell: globals.shell shell: globals.shell,
extraArgs: extraOptions
) )
} }
} }

View File

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