feat: Begins vault commands, adds nodes for rendering discussion documentation.
This commit is contained in:
23
Sources/hpa/VaultCommands/DecryptCommand.swift
Normal file
23
Sources/hpa/VaultCommands/DecryptCommand.swift
Normal file
@@ -0,0 +1,23 @@
|
||||
import ArgumentParser
|
||||
|
||||
struct DecryptCommand: AsyncParsableCommand {
|
||||
|
||||
static let commandName = "decrypt"
|
||||
|
||||
static let configuration = CommandConfiguration(
|
||||
commandName: commandName,
|
||||
abstract: createAbstract("Decrypt a vault file.")
|
||||
)
|
||||
|
||||
@OptionGroup var options: VaultOptions
|
||||
|
||||
@Option(
|
||||
name: .shortAndLong,
|
||||
help: "Output file."
|
||||
)
|
||||
var output: String?
|
||||
|
||||
mutating func run() async throws {
|
||||
fatalError()
|
||||
}
|
||||
}
|
||||
23
Sources/hpa/VaultCommands/EncryptCommand.swift
Normal file
23
Sources/hpa/VaultCommands/EncryptCommand.swift
Normal file
@@ -0,0 +1,23 @@
|
||||
import ArgumentParser
|
||||
|
||||
struct EncryptCommand: AsyncParsableCommand {
|
||||
|
||||
static let commandName = "encrypt"
|
||||
|
||||
static let configuration = CommandConfiguration(
|
||||
commandName: commandName,
|
||||
abstract: createAbstract("Encrypt a vault file.")
|
||||
)
|
||||
|
||||
@OptionGroup var options: VaultOptions
|
||||
|
||||
@Option(
|
||||
name: .shortAndLong,
|
||||
help: "Output file."
|
||||
)
|
||||
var output: String?
|
||||
|
||||
mutating func run() async throws {
|
||||
fatalError()
|
||||
}
|
||||
}
|
||||
14
Sources/hpa/VaultCommands/VaultCommand.swift
Normal file
14
Sources/hpa/VaultCommands/VaultCommand.swift
Normal file
@@ -0,0 +1,14 @@
|
||||
import ArgumentParser
|
||||
|
||||
struct VaultCommand: AsyncParsableCommand {
|
||||
|
||||
static let commandName = "vault"
|
||||
|
||||
static let configuration = CommandConfiguration(
|
||||
commandName: commandName,
|
||||
abstract: createAbstract("Vault commands."),
|
||||
subcommands: [
|
||||
EncryptCommand.self, DecryptCommand.self
|
||||
]
|
||||
)
|
||||
}
|
||||
31
Sources/hpa/VaultCommands/VaultOptions.swift
Normal file
31
Sources/hpa/VaultCommands/VaultOptions.swift
Normal file
@@ -0,0 +1,31 @@
|
||||
import ArgumentParser
|
||||
|
||||
// Holds the common options for vault commands, as they all share the
|
||||
// same structure.
|
||||
@dynamicMemberLookup
|
||||
struct VaultOptions: ParsableArguments {
|
||||
|
||||
@OptionGroup var globals: BasicGlobalOptions
|
||||
|
||||
@Option(
|
||||
name: .shortAndLong,
|
||||
help: "The vault file path.",
|
||||
completion: .file()
|
||||
)
|
||||
var file: String?
|
||||
|
||||
@Argument(
|
||||
help: "Extra arguments to pass to the vault command."
|
||||
)
|
||||
var extraArgs: [String] = []
|
||||
|
||||
subscript<T>(dynamicMember keyPath: WritableKeyPath<BasicGlobalOptions, T>) -> T {
|
||||
get { globals[keyPath: keyPath] }
|
||||
set { globals[keyPath: keyPath] = newValue }
|
||||
}
|
||||
|
||||
subscript<T>(dynamicMember keyPath: KeyPath<BasicGlobalOptions, T>) -> T {
|
||||
globals[keyPath: keyPath]
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user