Open myleshyson opened 1 month ago
Same with Swift 5.10. Using ParsableCommand
works just fine.
Have you tried removing mutating
?
Yea. Same result unfortunately.
My code structured like the following works when running command sub
. It uses Swift Argument Parser 1.5.0 on Swift 5.7.1 targeting macOS 10.15+. I do not have mutating
anywhere in my code:
import ArgumentParser
@main
struct Command: AsyncParsableCommand {
static let configuration = CommandConfiguration(
abstract: "…",
subcommands: [
Sub.self
]
)
}
extension Command {
struct Sub: AsyncParsableCommand {
func run() async throws {
try await …
}
}
}
I'm using Swift 6.0, and Im trying to use adhere to to the AsyncParsableCommand protocol. However I'm noticing that no matter what, my program always returns the help text instead of actually running.
There's post here describing this issue as well. Seems like the compiler favors the sync run command over the async run command.
Here's my main file. Just trying to print a string right now.
ArgumentParser version:
main
branch Swift version:swift-driver version: 1.113 Apple Swift version 6.0 (swiftlang-6.0.0.7.6 clang-1600.0.24.1) Target: arm64-apple-macosx14.0
.Checklist
main
branch of this packageSteps to Reproduce
mkdir MyCLI && cd MyCLI
swift package init --name MyCLI --type executable
Setup the entry file and add the argument parser package
Package.swift
Sources/main.swift
toSources/MyCLI.swift
@main struct MyCLI: AsyncParsableCommand { mutating func run() async throws { print("I'm working!") } }
Expected behavior
I'd expect when running
swift run MyCLI
that i would see "I'm working!" in the terminal.Actual behavior
Right now this always displays the help text.