Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extension SwiftPackageListPlugin.Configuration {
let outputType: OutputType?
let packageOrder: PackageOrder?
let requiresLicense: Bool? // swiftlint:disable:this discouraged_optional_boolean
let includePackages: [String]? // swiftlint:disable:this discouraged_optional_collection
let ignorePackages: [String]? // swiftlint:disable:this discouraged_optional_collection
let customPackagesFilePaths: [String]? // swiftlint:disable:this discouraged_optional_collection
}
Expand Down
4 changes: 4 additions & 0 deletions Plugins/SwiftPackageListPlugin/SwiftPackageListPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ struct SwiftPackageListPlugin: Plugin {
return ["--ignore-package", identity]
} ?? []

let includePackageArguments: [String] = targetConfiguration?.includePackages?.flatMap { identity in
return ["--include-package", identity]
} ?? []

let customPackagesFilePathArguments: [String] = targetConfiguration?.customPackagesFilePaths?.flatMap { filePath in
return ["--custom-packages-file-path", filePath]
} ?? []
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ In addition to that you can specify the following options:
| --package-order \<package-order\> | The order in which the packages will be listed. (values: source, name-ascending, name-descending, identity-ascending, identity-descending; default: source) |
| --requires-license | Will skip the packages without a license-file. |
| --ignore-package \<package-identity\> | Will skip a package with the specified identity. (This option may be repeated multiple times) |
| --include-package \<package-identity\> | Will include a package with the specified identity. Use when there are fewer to include than to ignore. (This option may be repeated multiple times) |
| --version | Show the version. |
| -h, --help | Show help information. |

Expand Down
13 changes: 13 additions & 0 deletions Sources/swift-package-list/SwiftPackageList+OutputOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ extension SwiftPackageList {
)
)
var ignoredPackageIdentities: [String] = []

@Option(
name: .customLong("include-package"),
help: ArgumentHelp(
"Will include a package with the specified identity. Use when there are fewer to include than to ignore. " +
"(This option may be repeated multiple times)",
valueName: "package-identity"
)
)
var includedPackageIdentities: [String] = []
}
}

Expand All @@ -61,6 +71,9 @@ extension SwiftPackageList.OutputOptions {
extension SwiftPackageList.OutputOptions {
func filter(package: Package) -> Bool {
if requiresLicense && !package.hasLicense { return false }
if !includedPackageIdentities.isEmpty {
return includedPackageIdentities.contains(package.identity) && !ignoredPackageIdentities.contains(package.identity)
}
return !ignoredPackageIdentities.contains(package.identity)
}

Expand Down