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(
quiet: Bool = false,
shell: String? = nil
shell: String? = nil,
extraArgs: [String]? = nil
) async throws {
guard let url = Bundle.module.url(forResource: "Brewfile", withExtension: nil) else {
throw CliClientError.brewfileNotFound
}
var arguments = [
"brew", "bundle",
"--file", url.cleanFilePath
]
if let extraArgs {
arguments.append(contentsOf: extraArgs)
}
try await runCommand(
quiet: quiet,
shell: shell.orDefault,
"brew", "bundle",
"--file", url.cleanFilePath
arguments
)
}

View File

@@ -21,9 +21,9 @@ struct BuildCommand: AsyncParsableCommand {
var projectDir: String
@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 {
try await _run()

View File

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

View File

@@ -25,7 +25,13 @@ func createAbstract(_ string: String) -> String {
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 {
HStack {
HStack {
@@ -37,11 +43,17 @@ extension Usage where Content == AnyTextNode {
}
.color(.blue).bold()
if usesOptions {
"[OPTIONS]".color(.green)
}
if usesArguments {
"[ARGUMENTS]".color(.cyan)
}
if usesExtraArguments {
"--"
"[EXTRA-OPTIONS]".color(.magenta)
}
}
.eraseToAnyTextNode()
}

View File

@@ -34,9 +34,9 @@ struct GenerateProjectTemplateCommand: AsyncParsableCommand {
var path: String
@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 {
@Dependency(\.cliClient) var cliClient

View File

@@ -9,6 +9,7 @@ struct InstallDependenciesCommand: AsyncParsableCommand {
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 {
@@ -18,6 +19,7 @@ struct InstallDependenciesCommand: AsyncParsableCommand {
"See Also:".yellow.bold.underline
"https://brew.sh"
}
ImportantNote.passingExtraArgs
}
.separator(.newLine(count: 2))
}
@@ -25,11 +27,17 @@ struct InstallDependenciesCommand: AsyncParsableCommand {
@OptionGroup var globals: BasicGlobalOptions
@Argument(
help: "Extra arguments / options to pass to the homebrew command."
)
var extraOptions: [String]
mutating func run() async throws {
@Dependency(\.cliClient) var cliClient
try await cliClient.installDependencies(
quiet: globals.quiet,
shell: globals.shell
shell: globals.shell,
extraArgs: extraOptions
)
}
}

View File

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