Skip to content

Commit f0f1f8b

Browse files
committed
Add include-package option
1 parent 5872c95 commit f0f1f8b

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

Plugins/SwiftPackageListPlugin/SwiftPackageListPlugin.Configuration.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extension SwiftPackageListPlugin.Configuration {
2121
let outputType: OutputType?
2222
let packageOrder: PackageOrder?
2323
let requiresLicense: Bool? // swiftlint:disable:this discouraged_optional_boolean
24+
let includePackages: [String]? // swiftlint:disable:this discouraged_optional_collection
2425
let ignorePackages: [String]? // swiftlint:disable:this discouraged_optional_collection
2526
let customPackagesFilePaths: [String]? // swiftlint:disable:this discouraged_optional_collection
2627
}

Plugins/SwiftPackageListPlugin/SwiftPackageListPlugin.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ struct SwiftPackageListPlugin: Plugin {
2626
return ["--ignore-package", identity]
2727
} ?? []
2828

29+
let includePackageArguments: [String] = targetConfiguration?.includePackages?.flatMap { identity in
30+
return ["--include-package", identity]
31+
} ?? []
32+
2933
let customPackagesFilePathArguments: [String] = targetConfiguration?.customPackagesFilePaths?.flatMap { filePath in
3034
return ["--custom-packages-file-path", filePath]
3135
} ?? []

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ In addition to that you can specify the following options:
6161
| --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) |
6262
| --requires-license | Will skip the packages without a license-file. |
6363
| --ignore-package \<package-identity\> | Will skip a package with the specified identity. (This option may be repeated multiple times) |
64+
| --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) |
6465
| --version | Show the version. |
6566
| -h, --help | Show help information. |
6667

Sources/swift-package-list/SwiftPackageList+OutputOptions.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ extension SwiftPackageList {
3838
)
3939
)
4040
var ignoredPackageIdentities: [String] = []
41+
42+
@Option(
43+
name: .customLong("include-package"),
44+
help: ArgumentHelp(
45+
"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)",
46+
valueName: "package-identity"
47+
)
48+
)
49+
var includedPackageIdentities: [String] = []
4150
}
4251
}
4352

@@ -61,6 +70,9 @@ extension SwiftPackageList.OutputOptions {
6170
extension SwiftPackageList.OutputOptions {
6271
func filter(package: Package) -> Bool {
6372
if requiresLicense && !package.hasLicense { return false }
73+
if !includedPackageIdentities.isEmpty {
74+
return includedPackageIdentities.contains(package.identity) && !ignoredPackageIdentities.contains(package.identity)
75+
}
6476
return !ignoredPackageIdentities.contains(package.identity)
6577
}
6678

0 commit comments

Comments
 (0)