Skip to content

Commit

Permalink
working through parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
leogdion committed Dec 27, 2024
1 parent 842efd7 commit b1e22a7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Sources/PackageDSLKit/PackageDSLKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@
//

import SwiftSyntax
import SwiftParser
import Foundation

enum PackageDSLError : Error {
case custom(String, (any Sendable)?)
case other(any Error)
}
extension ImportDeclSyntax {

static func module(_ moduleName: String) -> ImportDeclSyntax {
ImportDeclSyntax(
path: ImportPathComponentListSyntax([
Expand All @@ -42,6 +49,15 @@ extension ImportDeclSyntax {
}
}
public enum PackageDSLKit {

static func parse(_ directoryURL: URL, with fileManager: FileManager) throws {
let indexFileURL = directoryURL.appendingPathComponent("Index.swift")
guard fileManager.fileExists(atPath: indexFileURL.path) else {
throw PackageDSLError.custom("Could not find Index.swift file at \(indexFileURL)", indexFileURL)
}
let sourceCode = try String(contentsOf: indexFileURL)
}

public static func labeledExpression(for name: String, items: [String]) -> LabeledExprSyntax {
LabeledExprSyntax(
leadingTrivia: .newline,
Expand Down
18 changes: 17 additions & 1 deletion Sources/package/Commands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ enum FileManagerType : String, CaseIterable, ExpressibleByArgument {
case fileManager
}

enum ProductType : String, CaseIterable, ExpressibleByArgument {
case library
case executable
}
extension Package {
struct Initialize : ParsableCommand {
@OptionGroup var settings: Settings
Expand Down Expand Up @@ -131,13 +135,25 @@ extension Package.Target {

extension Package {
struct Product : ParsableCommand {

static let configuration: CommandConfiguration = .init(
subcommands: [Add.self]
)
}
}

extension Package.Product {
struct Add : ParsableCommand {
@Argument var name : String

@OptionGroup var settings: Settings

@Option var type : ProductType = .library

func run() throws {
// add to products directory
// add to index

}
}
}

Expand Down

0 comments on commit b1e22a7

Please sign in to comment.