apple / apple/swift-argument-parser

AsyncParsableCommand exits before running `run() async`

Open
#538 6 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Swift
Stars
3.8k
Forks
411
Avg merge
7d 13h
Merged PRs (30d)
17

Description

When using an AsyncParsableCommand with @main, the command-line-tool exits without running the `run() async` function and prints the help log.
Note: `run()` without `async` runs the function.

**ArgumentParser version:** `1.2.0`
**Swift version:** swift-driver version: 1.45.2 Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)
**MacOS** 12.6
### Checklist
- [x] If possible, I've reproduced the issue using the `main` branch of this package
- [x] I've searched for [existing GitHub issues](https://github.com/apple/swift-argument-parser/issues)

### Steps to Reproduce
Option A: Reproduce by running the [Example in this repository](https://github.com/apple/swift-argument-parser/blob/main/Examples/count-lines/CountLines.swift)

Option B:
![Screenshot 2023-01-06 at 10 36 30](https://user-images.githubusercontent.com/5910320/210991006-7ad472d9-112b-4a8b-9397-f14ca1010ac1.png)

### Expected behavior
The `run() async` function should run

### Actual behavior
The `run() async` function isn't run and the program exits with the help log.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with Examples/count-lines/CountLines.swift, focusing on its AsyncParsableCommand entry point and the difference between run() and run() async. Confirm that the async function is skipped and help is printed; done means the async run() executes for the documented example instead of exiting with the help log.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.