Skip to content

AsyncParsableCommand never runs. Only shows help text.  #662

@myleshyson

Description

@myleshyson

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.

import ArgumentParser

@main
struct PhpFlayer: AsyncParsableCommand {
    mutating func run() async throws {
        print("I'm working!")
    }
}

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

  • [x ] If possible, I've reproduced the issue using the main branch of this package
  • [x ] I've searched for existing GitHub issues

Steps to Reproduce

  1. Create an empty project
    • mkdir MyCLI && cd MyCLI
    • swift package init --name MyCLI --type executable
  2. Setup the entry file and add the argument parser package
    • Add the argument parser package to Package.swift
    • rename Sources/main.swift to Sources/MyCLI.swift
    • setup the following main struct
    import ArgumentParser
    
    @main
    struct MyCLI: AsyncParsableCommand {
        mutating func run() async throws {
            print("I'm working!")
        }
    }
  3. Run the program and see only help text show up instead of "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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions