mirror of
https://github.com/apple/container.git
synced 2026-10-12 17:19:13 +00:00
Remove PLUGINS section from help message (#2309)
This commit is contained in:
1 parent
2e23485f62
commit
6fba624647
2 files changed
+15
-8
No files matched your search
@@ -217,7 +217,7 @@ extension Application {
|
||||
let original = Application.helpMessage(for: Application.self)
|
||||
guard let pluginLoader else {
|
||||
print(addGroupSpacing(original))
|
||||
print("\nPLUGINS: not available, run `container system start`")
|
||||
print("\n[Warning] CLI plugins not available, run `container system start`")
|
||||
return
|
||||
}
|
||||
let altered = pluginLoader.alterCLIHelpText(original: original)
|
||||
@@ -227,7 +227,6 @@ extension Application {
|
||||
private static func addGroupSpacing(_ text: String) -> String {
|
||||
text
|
||||
.replacingOccurrences(of: "\n([A-Z].+SUBCOMMANDS:)", with: "\n\n$1", options: .regularExpression)
|
||||
.replacingOccurrences(of: "\nPLUGINS:", with: "\n\nPLUGINS:")
|
||||
}
|
||||
|
||||
func isTranslated() throws -> Bool {
|
||||
|
||||
@@ -76,15 +76,23 @@ extension PluginLoader {
|
||||
}
|
||||
|
||||
var lines = original.split(separator: "\n").map { String($0) }
|
||||
let pluginLines = plugins.map { $0.helpText(padding: 24) }
|
||||
|
||||
let sectionHeader = "PLUGINS:"
|
||||
lines.append(sectionHeader)
|
||||
|
||||
for plugin in plugins {
|
||||
let helpText = plugin.helpText(padding: 24)
|
||||
lines.append(helpText)
|
||||
// List plugin CLI surfaces alongside the built-in "other" commands
|
||||
// rather than under their own section, since from the user's
|
||||
// perspective they're just more subcommands.
|
||||
guard let otherHeaderIndex = lines.firstIndex(of: "OTHER SUBCOMMANDS:") else {
|
||||
lines.append("OTHER SUBCOMMANDS:")
|
||||
lines.append(contentsOf: pluginLines)
|
||||
return lines.joined(separator: "\n")
|
||||
}
|
||||
|
||||
var insertionIndex = otherHeaderIndex + 1
|
||||
while insertionIndex < lines.count, lines[insertionIndex].hasPrefix(" ") {
|
||||
insertionIndex += 1
|
||||
}
|
||||
lines.insert(contentsOf: pluginLines, at: insertionIndex)
|
||||
|
||||
return lines.joined(separator: "\n")
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user