Skip to content

Commit 95214d0

Browse files
committed
[Commands] SE-0481: Align the arguments to --target and --to-feature and allow a comma separated list
1 parent 9d2d5fa commit 95214d0

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

Sources/Commands/PackageCommands/Migrate.swift

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,23 @@ import var TSCBasic.stdoutStream
3232
struct MigrateOptions: ParsableArguments {
3333
@Option(
3434
name: .customLong("target"),
35-
parsing: .upToNextOption,
3635
help: "The targets to migrate to specified set of features."
3736
)
38-
var targets: [String] = []
37+
var _targets: String?
38+
39+
var targets: OrderedSet<String> {
40+
self._targets.flatMap { OrderedSet($0.components(separatedBy: ",")) } ?? []
41+
}
3942

4043
@Option(
4144
name: .customLong("to-feature"),
42-
parsing: .upToNextOption,
4345
help: "The Swift language upcoming/experimental feature to migrate to."
4446
)
45-
var features: [String]
47+
var _features: String
48+
49+
var features: Set<String> {
50+
Set(self._features.components(separatedBy: ","))
51+
}
4652
}
4753

4854
extension SwiftPackageCommand {
@@ -84,20 +90,20 @@ extension SwiftPackageCommand {
8490
features.append(feature)
8591
}
8692

87-
let uniqueTargets = OrderedSet(self.options.targets)
93+
let targets = self.options.targets
8894

8995
let buildSystem = try await createBuildSystem(
9096
swiftCommandState,
91-
targets: uniqueTargets,
97+
targets: targets,
9298
features: features
9399
)
94100

95101
// Next, let's build all of the individual targets or the
96102
// whole project to get diagnostic files.
97103

98104
print("> Starting the build")
99-
if !uniqueTargets.isEmpty {
100-
for target in uniqueTargets {
105+
if !targets.isEmpty {
106+
for target in targets {
101107
try await buildSystem.build(subset: .target(target))
102108
}
103109
} else {
@@ -108,9 +114,9 @@ extension SwiftPackageCommand {
108114
let buildPlan = try buildSystem.buildPlan
109115

110116
var modules: [any ModuleBuildDescription] = []
111-
if !uniqueTargets.isEmpty {
117+
if !targets.isEmpty {
112118
for buildDescription in buildPlan.buildModules
113-
where uniqueTargets.contains(buildDescription.module.name) {
119+
where targets.contains(buildDescription.module.name) {
114120
modules.append(buildDescription)
115121
}
116122
} else {

0 commit comments

Comments
 (0)