-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueriesCommand.swift
More file actions
37 lines (29 loc) · 1005 Bytes
/
QueriesCommand.swift
File metadata and controls
37 lines (29 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// QueriesCommand.swift
// PureSQL
//
// Created by Wes Wickwire on 5/21/25.
//
import ArgumentParser
import Compiler
import Foundation
struct QueriesCommand: ParsableCommand {
static let configuration = CommandConfiguration(
commandName: "queries",
subcommands: [Add.self]
)
struct Add: ParsableCommand {
@Option(name: .shortAndLong, help: "The directory containing the puresql.yaml")
var path: String = FileManager.default.currentDirectoryPath
@Argument var name: String
static let configuration = CommandConfiguration(commandName: "add")
func run() throws {
let config = try Config(at: path)
let project = try config.project(at: path)
guard !project.doesQueryExist(withName: name) else {
throw SQLError.queryAlreadyExists(fileName: name)
}
try project.addQuery(named: name)
}
}
}