Skip to content

Commit 2748c0d

Browse files
committed
fix: update snapshots and solve merge conflict
2 parents 7659317 + c3bdeba commit 2748c0d

29 files changed

+212
-40
lines changed

.github/workflows/pull_request.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
with:
2727
windows_exclude_swift_versions: "[{\"swift_version\": \"5.9\"}]"
2828
enable_macos_checks: true
29+
macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.0\"}, {\"xcode_version\": \"16.1\"}]"
2930

3031
cmake-build:
3132
name: CMake Build
@@ -50,6 +51,25 @@ jobs:
5051
- name: Build
5152
run: cmake --build .cmake-build
5253

54+
wasm-build:
55+
name: Wasm Build
56+
runs-on: ubuntu-latest
57+
container:
58+
image: swift:6.1-noble
59+
steps:
60+
- name: Checkout repo
61+
uses: actions/checkout@v4
62+
- name: Install Swift SDKs for WebAssembly
63+
run: |
64+
# TODO: We can replace these Swift SDKs with the swift.org one once it supports Foundation.
65+
swift sdk install https://github.com/swiftwasm/swift/releases/download/swift-wasm-6.1-RELEASE/swift-wasm-6.1-RELEASE-wasm32-unknown-wasi.artifactbundle.zip --checksum 7550b4c77a55f4b637c376f5d192f297fe185607003a6212ad608276928db992
66+
swift sdk install https://github.com/swiftwasm/swift/releases/download/swift-wasm-6.1-RELEASE/swift-wasm-6.1-RELEASE-wasm32-unknown-wasip1-threads.artifactbundle.zip --checksum 0dd273be28741f8e1eb00682c39bdc956361ed24b5572e183dd8a4e9d1c5f6ec
67+
swift sdk list
68+
- name: Build
69+
run: |
70+
swift build --swift-sdk wasm32-unknown-wasi --target ArgumentParser
71+
swift build --swift-sdk wasm32-unknown-wasip1-threads --target ArgumentParser
72+
5373
soundness:
5474
name: Soundness
5575
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main

CHANGELOG.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ Add new items at the end of the relevant section under **Unreleased**.
66

77
## [Unreleased]
88

9+
---
10+
11+
## [1.6.1] - 2025-07-01
12+
13+
### Fixes
14+
15+
- Resolves a source break for clients that have conditional conformances
16+
to `ExpressibleByArgument` or `ParsableArguments`. ([#792])
17+
18+
## [1.6.0] - 2025-06-30
19+
920
### Additions
1021

1122
- Options with `CaseIterable` types can now provide help descriptions on a per-value basis. ([#647])
@@ -16,6 +27,8 @@ Add new items at the end of the relevant section under **Unreleased**.
1627

1728
- Testing and continuous integration improvements, including migrating to GitHub workflows.
1829
([#692], [#693], [#696], [#698], [#699], [#700], [#701], [#708], [#711], [#718], [#716], [#714], [#712], [#732], [#730], [#746], [#747], [#760])
30+
- The associated closure for `CompletionKind.custom` now takes three parameters: the array of shell words currently in use for the completion request, the offset in that array for the word that completions are being requested for, and the prefix of that word that precedes the cursor. In addition, the associated closure can be `async`. The single-argument closure version of `CompletionKind.custom` is deprecated with this release. ([#763], [#770], [#782])
31+
- `ParsableArguments` and `ExpressibleByArgument` now conform to `SendableMetatype` when builing with a minimum Swift 6.2 compiler. ([#789])
1932

2033
### Fixes
2134

@@ -30,6 +43,10 @@ Add new items at the end of the relevant section under **Unreleased**.
3043
- Better capturing of tool configuration in `ToolInfo`. ([#669], [#697])
3144
- Documentation improvements. ([#657], [#678], [#743])
3245

46+
The 1.6.0 release includes contributions from [bripeticca], [cg-soft], [compnerd],
47+
[dshan4585], [heckj], [natecook1000], [rauhul], [rgoldberg], and [Steelskin].
48+
Thank you!
49+
3350
---
3451

3552
## [1.5.1] - 2025-05-28
@@ -943,7 +960,9 @@ This changelog's format is based on [Keep a Changelog](https://keepachangelog.co
943960

944961
<!-- Link references for releases -->
945962

946-
[Unreleased]: https://github.com/apple/swift-argument-parser/compare/1.5.1...HEAD
963+
[Unreleased]: https://github.com/apple/swift-argument-parser/compare/1.6.1...HEAD
964+
[1.6.1]: https://github.com/apple/swift-argument-parser/compare/1.6.0...1.6.1
965+
[1.6.0]: https://github.com/apple/swift-argument-parser/compare/1.5.1...1.6.0
947966
[1.5.1]: https://github.com/apple/swift-argument-parser/compare/1.5.0...1.5.1
948967
[1.5.0]: https://github.com/apple/swift-argument-parser/compare/1.4.0...1.5.0
949968
[1.4.0]: https://github.com/apple/swift-argument-parser/compare/1.3.1...1.4.0
@@ -1130,7 +1149,10 @@ This changelog's format is based on [Keep a Changelog](https://keepachangelog.co
11301149
[#773]: https://github.com/apple/swift-argument-parser/pull/773
11311150
[#775]: https://github.com/apple/swift-argument-parser/pull/775
11321151
[#777]: https://github.com/apple/swift-argument-parser/pull/777
1152+
[#782]: https://github.com/apple/swift-argument-parser/pull/782
11331153
[#783]: https://github.com/apple/swift-argument-parser/pull/783
1154+
[#789]: https://github.com/apple/swift-argument-parser/pull/789
1155+
[#792]: https://github.com/apple/swift-argument-parser/pull/792
11341156

11351157
<!-- Link references for contributors -->
11361158

@@ -1144,7 +1166,9 @@ This changelog's format is based on [Keep a Changelog](https://keepachangelog.co
11441166
[atierian]: https://github.com/apple/swift-argument-parser/commits?author=atierian
11451167
[Austinpayne]: https://github.com/apple/swift-argument-parser/commits?author=Austinpayne
11461168
[BradLarson]: https://github.com/apple/swift-argument-parser/commits?author=BradLarson
1169+
[bripeticca]: https://github.com/apple/swift-argument-parser/commits?author=bripeticca
11471170
[buttaface]: https://github.com/apple/swift-argument-parser/commits?author=buttaface
1171+
[cg-soft]: https://github.com/apple/swift-argument-parser/commits?author=cg-soft
11481172
[Chamepp]: https://github.com/apple/swift-argument-parser/commits?author=Chamepp
11491173
[clayellis]: https://github.com/apple/swift-argument-parser/commits?author=clayellis
11501174
[CodaFi]: https://github.com/apple/swift-argument-parser/commits?author=CodaFi
@@ -1159,6 +1183,7 @@ This changelog's format is based on [Keep a Changelog](https://keepachangelog.co
11591183
[dirtyhabits97]: https://github.com/apple/swift-argument-parser/commits?author=dirtyhabits97
11601184
[DougGregor]: https://github.com/apple/swift-argument-parser/commits?author=DougGregor
11611185
[drewmccormack]: https://github.com/apple/swift-argument-parser/commits?author=drewmccormack
1186+
[dshan4585]: https://github.com/apple/swift-argument-parser/commits?author=dshan4585
11621187
[elliottwilliams]: https://github.com/apple/swift-argument-parser/commits?author=elliottwilliams
11631188
[erica]: https://github.com/apple/swift-argument-parser/commits?author=erica
11641189
[finagolfin]: https://github.com/apple/swift-argument-parser/commits?author=finagolfin
@@ -1169,6 +1194,7 @@ This changelog's format is based on [Keep a Changelog](https://keepachangelog.co
11691194
[gmittert]: https://github.com/apple/swift-argument-parser/commits?author=gmittert
11701195
[griffin-stewie]: https://github.com/apple/swift-argument-parser/commits?author=griffin-stewie
11711196
[gwynne]: https://github.com/apple/swift-argument-parser/commits?author=gwynne
1197+
[heckj]: https://github.com/apple/swift-argument-parser/commits?author=heckj
11721198
[iainsmith]: https://github.com/apple/swift-argument-parser/commits?author=iainsmith
11731199
[ian-twilightcoder]: https://github.com/apple/swift-argument-parser/commits?author=ian-twilightcoder
11741200
[ibrahimoktay]: https://github.com/apple/swift-argument-parser/commits?author=ibrahimoktay
@@ -1206,6 +1232,7 @@ This changelog's format is based on [Keep a Changelog](https://keepachangelog.co
12061232
[randomeizer]: https://github.com/apple/swift-argument-parser/commits?author=randomeizer
12071233
[rauhul]: https://github.com/apple/swift-argument-parser/commits?author=rauhul
12081234
[revolter]: https://github.com/apple/swift-argument-parser/commits?author=revolter
1235+
[rgoldberg]: https://github.com/apple/swift-argument-parser/commits?author=rgoldberg
12091236
[rickrizzo]: https://github.com/apple/swift-argument-parser/commits?author=rickrizzo
12101237
[rjstelling]: https://github.com/apple/swift-argument-parser/commits?author=rjstelling
12111238
[robertmryan]: https://github.com/apple/swift-argument-parser/commits?author=robertmryan
@@ -1215,6 +1242,7 @@ This changelog's format is based on [Keep a Changelog](https://keepachangelog.co
12151242
[sgl0v]: https://github.com/apple/swift-argument-parser/commits?author=sgl0v
12161243
[sharplet]: https://github.com/apple/swift-argument-parser/commits?author=sharplet
12171244
[sjavora]: https://github.com/apple/swift-argument-parser/commits?author=sjavora
1245+
[Steelskin]: https://github.com/apple/swift-argument-parser/commits?author=Steelskin
12181246
[stuartcarnie]: https://github.com/apple/swift-argument-parser/commits?author=stuartcarnie
12191247
[thomasvl]: https://github.com/apple/swift-argument-parser/commits?author=thomasvl
12201248
[TiagoMaiaL]: https://github.com/apple/swift-argument-parser/commits?author=TiagoMaiaL

Examples/repeat/Repeat.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import ArgumentParser
1313

1414
@main
1515
struct Repeat: ParsableCommand {
16-
@Option(help: "The number of times to repeat 'phrase'.")
16+
@Option(help: "How many times to repeat 'phrase'.")
1717
var count: Int? = nil
1818

1919
@Flag(help: "Include a counter with each repetition.")

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct Repeat: ParsableCommand {
1818
@Flag(help: "Include a counter with each repetition.")
1919
var includeCounter = false
2020

21-
@Option(name: .shortAndLong, help: "The number of times to repeat 'phrase'.")
21+
@Option(name: .shortAndLong, help: "How many times to repeat 'phrase'.")
2222
var count: Int? = nil
2323

2424
@Argument(help: "The phrase to repeat.")

Sources/ArgumentParser/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ add_library(ArgumentParser
4646
Utilities/Platform.swift
4747
Utilities/SequenceExtensions.swift
4848
Utilities/StringExtensions.swift
49+
Utilities/SwiftExtensions.swift
4950
Utilities/Tree.swift
5051

5152
Validators/CodingKeyValidator.swift

Sources/ArgumentParser/Parsable Properties/CompletionKind.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public struct CompletionKind {
4141
case directory
4242
case shellCommand(String)
4343
case custom(@Sendable ([String], Int, String) -> [String])
44+
#if !canImport(Dispatch)
45+
@available(*, unavailable, message: "DispatchSemaphore is unavailable")
46+
#endif
4447
case customAsync(@Sendable ([String], Int, String) async -> [String])
4548
case customDeprecated(@Sendable ([String]) -> [String])
4649
}
@@ -181,11 +184,18 @@ public struct CompletionKind {
181184
///
182185
/// The same as `custom(@Sendable @escaping ([String], Int, String) -> [String])`,
183186
/// except that the closure is asynchronous.
187+
#if !canImport(Dispatch)
188+
@available(*, unavailable, message: "DispatchSemaphore is unavailable")
189+
#endif
184190
@available(macOS 10.15, macCatalyst 13, iOS 13, tvOS 13, watchOS 6, *)
185191
public static func custom(
186192
_ completion: @Sendable @escaping ([String], Int, String) async -> [String]
187193
) -> CompletionKind {
194+
#if !canImport(Dispatch)
195+
fatalError("DispatchSemaphore is unavailable")
196+
#else
188197
CompletionKind(kind: .customAsync(completion))
198+
#endif
189199
}
190200

191201
/// Deprecated; only kept for backwards compatibility.

Sources/ArgumentParser/Parsable Types/ExpressibleByArgument.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
/// A type that can be expressed as a command-line argument.
13-
public protocol ExpressibleByArgument {
13+
public protocol ExpressibleByArgument: _SendableMetatype {
1414
/// Creates a new instance of this type from a command-line-specified
1515
/// argument.
1616
init?(argument: String)

Sources/ArgumentParser/Parsable Types/ParsableArguments.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
///
1414
/// When you implement a `ParsableArguments` type, all properties must be declared with
1515
/// one of the four property wrappers provided by the `ArgumentParser` library.
16-
public protocol ParsableArguments: Decodable {
16+
public protocol ParsableArguments: Decodable, _SendableMetatype {
1717
/// Creates an instance of this parsable type using the definitions
1818
/// given by each property's wrapper.
1919
init()

Sources/ArgumentParser/Parsing/CommandParser.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
#if swift(>=6.0)
13+
#if canImport(Dispatch)
1314
@preconcurrency private import class Dispatch.DispatchSemaphore
15+
#endif
1416
internal import class Foundation.NSLock
1517
internal import class Foundation.ProcessInfo
1618
#else
19+
#if canImport(Dispatch)
1720
@preconcurrency import class Dispatch.DispatchSemaphore
21+
#endif
1822
import class Foundation.NSLock
1923
import class Foundation.ProcessInfo
2024
#endif
@@ -474,12 +478,16 @@ extension CommandParser {
474478
completingPrefix
475479
)
476480
case .customAsync(let complete):
481+
#if canImport(Dispatch)
477482
if #available(macOS 10.15, macCatalyst 13, iOS 13, tvOS 13, watchOS 6, *)
478483
{
479484
completions = try asyncCustomCompletions(from: args, complete: complete)
480485
} else {
481486
throw ParserError.invalidState
482487
}
488+
#else
489+
throw ParserError.invalidState
490+
#endif
483491
case .customDeprecated(let complete):
484492
completions = complete(args)
485493
default:
@@ -528,11 +536,17 @@ private func parseCustomCompletionArguments(
528536
return (Array(args), completingArgumentIndex, completingPrefix)
529537
}
530538

539+
#if !canImport(Dispatch)
540+
@available(*, unavailable, message: "DispatchSemaphore is unavailable")
541+
#endif
531542
@available(macOS 10.15, macCatalyst 13, iOS 13, tvOS 13, watchOS 6, *)
532543
private func asyncCustomCompletions(
533544
from args: [String],
534545
complete: @escaping @Sendable ([String], Int, String) async -> [String]
535546
) throws -> [String] {
547+
#if !canImport(Dispatch)
548+
throw ParserError.invalidState
549+
#else
536550
let (args, completingArgumentIndex, completingPrefix) =
537551
try parseCustomCompletionArguments(from: args)
538552

@@ -550,6 +564,7 @@ private func asyncCustomCompletions(
550564

551565
semaphore.wait()
552566
return completionsBox.value
567+
#endif
553568
}
554569

555570
// Helper class to make values sendable across concurrency boundaries
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift Argument Parser open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
//
10+
//===----------------------------------------------------------------------===//
11+
12+
#if compiler(>=6.2)
13+
/// Designates a type as having a sendable metatype.
14+
@_marker public protocol _SendableMetatype: SendableMetatype {}
15+
#else
16+
@_marker public protocol _SendableMetatype {}
17+
#endif

0 commit comments

Comments
 (0)