import ArgumentParser import Foundation struct MinimumsCommand: AsyncParsableCommand { static let configuration = CommandConfiguration( commandName: "minimums", abstract: String( localized: "Inspect or forget learned application minimum sizes.", table: "Minimums", bundle: .module), subcommands: [MinimumsListCommand.self, MinimumsResetCommand.self], defaultSubcommand: MinimumsListCommand.self) } struct MinimumsListCommand: CLICommand { static let configuration = CommandConfiguration( commandName: "list", abstract: String(localized: "List confirmed minimum sizes by application.", table: "Minimums", bundle: .module)) @OptionGroup var output: CLIOptions var invocation: CLIInvocation { .engine("minimums-list", args: [], json: output.json) } } struct MinimumsResetCommand: CLICommand { static let configuration = CommandConfiguration( commandName: "reset", abstract: String( localized: "Forget learned minimum sizes for one application, or all applications.", table: "Minimums", bundle: .module)) @OptionGroup var output: CLIOptions @Argument( help: ArgumentHelp( String( localized: "Application bundle identifier. Omit to reset every application.", table: "Minimums", bundle: .module))) var bundle: String? mutating func validate() throws { if let bundle, bundle.isEmpty || bundle.contains(where: \.isWhitespace) { throw ValidationError( String( localized: "Provide a nonempty bundle identifier without whitespace.", table: "Minimums", bundle: .module)) } } var invocation: CLIInvocation { .engine("minimums-reset", args: bundle.map { [$0] } ?? [], json: output.json) } }