import ArgumentParser import SwiftLintFramework extension SwiftLint { struct Build: AsyncParsableCommand { static let configuration = CommandConfiguration(abstract: "Print lint warnings and errors") @OptionGroup var common: LintOrAnalyzeArguments @Option(help: pathOptionDescription(for: .build)) var path: String? @Flag(help: quietOptionDescription(for: .build)) var quiet = false @Option(help: "The directory of the cache used when linting.") var cachePath: String? @Flag(help: "Ignore cache when linting.") var noCache = false @Flag(help: "Run all rules, even opt-in and disabled ones, ignoring `only_rules`.") var enableAllRules = false @Argument(help: pathsArgumentDescription(for: .build)) var paths = [String]() func run() async throws { let allPaths: [String] if let path { queuedPrintError(""" warning: The --path option is deprecated. Pass the path(s) to lint last to the swiftlint command. """) allPaths = [path] + paths } else if !paths.isEmpty { allPaths = paths } else { allPaths = [""] // Lint files in current working directory if no paths were specified. } let options = LintOrAnalyzeOptions( mode: .build, paths: allPaths, configurationFiles: common.config, strict: common.leniency == .strict, lenient: common.leniency == .lenient, forceExclude: common.forceExclude, useExcludingByPrefix: common.useAlternativeExcluding, useScriptInputFiles: common.useScriptInputFiles, benchmark: common.benchmark, reporter: common.reporter, quiet: quiet, output: common.output, progress: common.progress, cachePath: cachePath, ignoreCache: noCache, enableAllRules: enableAllRules, autocorrect: common.fix, format: common.format, compilerLogPath: nil, compileCommands: nil, inProcessSourcekit: common.inProcessSourcekit ) try await LintOrAnalyzeCommand.run(options) } } }