AsyncParsableCommand

0.0.3

Drop-in replacement for ParsableCommand to use async/await in swift-argument-parser commands
christopherweems/_AsyncParsableCommand

What's New

_AsyncParsableCommand 0.0.3

2021-10-05T17:08:43Z

Conditionally skip async test on non-macOS targets (async tests fail on Linux)

_AsyncParsableCommand

A drop-in replacement for ParsableCommand allowing you to use async/await in ParsableCommand.run() without managing tasks.

Hopefully just here to hold you over until async/await support lands in swift-argument-parser.

Usage

import ArgumentParser
import AsyncParsableCommand

struct Countdown: _AsyncParsableCommand {
    @Argument var count: Int
    
    func run() async throws {
        var remaining = count
        
        while 0 < remaining {
            print("\(remaining)!")
            await Task.sleep(1_000_000_000)
            remaining -= 1
        }
        
        print("Countdown complete!")
        
    }
    
}

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

Last updated: Mon Oct 21 2024 11:40:57 GMT-0900 (Hawaii-Aleutian Daylight Time)