Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions Tools/generate-command-models/GenerateCommandModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,28 +277,16 @@ struct GenerateCommandModels: AsyncParsableCommand {
"""
}

let argumentsFunc: String
if path.count == 0 {
argumentsFunc = """
public func commandArgs() -> [String] {
var genArgs: [String] = []

\((options.asArgs + vars.asArgs).joined(separator: "\n" + indent(1)))

return genArgs
}
""".split(separator: "\n", omittingEmptySubsequences: false).joined(separator: "\n" + indent(1))
} else {
argumentsFunc = """
public func commandArgs() -> [String] {
var genArgs: [String] = self.parent.commandArgs() + ["\(execName)"]
let genArgs = options.asArgs + vars.asArgs
let argumentsFunc = """
public func commandArgs() -> [String] {
\(genArgs.isEmpty ? "let" : "var") genArgs: [String] = \(path.count == 0 ? "[]" : "self.parent.commandArgs() + [\"\(execName)\"]")

\((options.asArgs + vars.asArgs).joined(separator: "\n" + indent(1)))
\(genArgs.joined(separator: "\n" + indent(1)))

return genArgs
}
""".split(separator: "\n", omittingEmptySubsequences: false).joined(separator: "\n" + indent(1))
return genArgs
}
""".split(separator: "\n", omittingEmptySubsequences: false).joined(separator: "\n" + indent(1))

let configFunc: String
if path.count == 0 {
Expand Down