Note: this is all assuming the Package.swift
contains the proper minimum platform versions.
If I try and make a root AsyncParseableCommand
in a main.swift
of an executable target like so:
import ArgumentParser
struct MyCommand: AsyncParsableCommand {
func run() async {
print("Hello, World!")
}
}
MyCommand.main()
the resulting binary will print the help text instead of running the command. If I use @main
in a main.swift
, the Swift compiler complains that I cannot use @main
in a file that contains top-level code. If, instead, I make another file (let's say foo.swift
) like so:
import ArgumentParser
@main
struct MyCommand: AsyncParsableCommand {
func run() async {
print("Hello, World!")
}
}
the binary will run the command as expected.
Is this a known issue?