import ArgumentParser import ConfigurationClient import Dependencies import Foundation import Logging import PlaybookClient struct CreateCommand: AsyncParsableCommand { static let commandName = "create" static let configuration = CommandConfiguration.playbook( commandName: commandName, abstract: "Create a home performance assesment project.", examples: ( label: "Create Assesment", example: "\(commandName) /new/assement/path" ) ) @OptionGroup var globals: GlobalOptions @Option( name: .shortAndLong, help: "The template repository to use." ) var repo: String? @Option( name: .shortAndLong, help: "The repo branch or version to use." ) var branch: String? @Option( name: .shortAndLong, help: "Path to local template directory to use.", completion: .directory ) var templateDir: String? @Flag( name: [ .short, .customLong("use-local-template") ], help: "Force using a local template directory." ) var localTemplateDir = false @Argument( help: "Path to the project directory.", completion: .directory ) var projectDir: String @Argument( help: "Extra arguments passed to the playbook." ) var extraOptions: [String] = [] mutating func run() async throws { @Dependency(\.playbookClient) var playbookClient try await playbookClient.run.createProject(.init( projectDirectory: projectDir, shared: globals.sharedPlaybookRunOptions( commandName: Self.commandName, extraOptions: extraOptions ), template: .init(directory: templateDir), useLocalTemplateDirectory: localTemplateDir )) print(projectDir) } }