Skip to content

Commit

Permalink
Embed Program into library to simplify main (#572)
Browse files Browse the repository at this point in the history
Following [this
suggestion](apple/swift-argument-parser#688 (comment)),
thanks!
  • Loading branch information
bolsinga authored Dec 31, 2024
1 parent 4a39d98 commit 5228bce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
14 changes: 14 additions & 0 deletions Sources/iTunes/Program.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import ArgumentParser
import Foundation

public struct Program: AsyncParsableCommand {
public static let configuration = CommandConfiguration(
commandName: "tunes",
abstract: "A tool for working with iTunes data.",
version: iTunesVersion,
subcommands: [BackupCommand.self, PatchCommand.self, RepairCommand.self, BatchCommand.self],
defaultSubcommand: BackupCommand.self
)

public init() {} // This is public and empty to help the compiler.
}
15 changes: 4 additions & 11 deletions Sources/tunes/Program.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import ArgumentParser
import Foundation
import iTunes

@main
public struct Program: AsyncParsableCommand {
public static let configuration = CommandConfiguration(
commandName: "tunes",
abstract: "A tool for working with iTunes data.",
version: iTunesVersion,
subcommands: [BackupCommand.self, PatchCommand.self, RepairCommand.self, BatchCommand.self],
defaultSubcommand: BackupCommand.self
)

public init() {} // This is public and empty to help the compiler.
public struct Main {
static func main() async {
await Program.main()
}
}

0 comments on commit 5228bce

Please sign in to comment.