diff --git a/Sources/ContainerCommands/Application.swift b/Sources/ContainerCommands/Application.swift index 3d917c60..1cfc9b22 100644 --- a/Sources/ContainerCommands/Application.swift +++ b/Sources/ContainerCommands/Application.swift @@ -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 { diff --git a/Sources/ContainerPlugin/PluginLoader.swift b/Sources/ContainerPlugin/PluginLoader.swift index 7285efa8..3cda8fca 100644 --- a/Sources/ContainerPlugin/PluginLoader.swift +++ b/Sources/ContainerPlugin/PluginLoader.swift @@ -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") }