Skip to content

Instantly share code, notes, and snippets.

func run() throws {
print(template)
print(attributes)
}
enum CodingKeys: CodingKey {
case template
case dynamic(String)
init?(stringValue: String) {
switch stringValue {
case "template":
self = .template
case stringValue where Scaffold.attributes.contains(stringValue):
self = .dynamic(stringValue)
enum CodingKeys: String, CodingKey {
case template
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
template = try container.decode(Argument<String>.self, forKey: .template).wrappedValue
}
// Necessary for conforming ParsableArguments
@Option(name: .shortAndLong)
var name: String
extension Scaffold: CustomReflectable {
var customMirror: Mirror {
// #1
let attributesChildren: [Mirror.Child] = Scaffold.attributes
// #2
.map {
(name: $0, option: Option<String>(name: .shortAndLong))
}
// #3
.map {
static var attributes: [String] = []
static func preprocess(_ arguments: [String]) throws {
...
let attributes: [String] = try JSONDecoder().decode([String].self, from: data)
Scaffold.attributes = attributes
}
extension ArgumentSet {
init(_ type: ParsableArguments.Type) {
let a: [ArgumentSet] = Mirror(reflecting: type.init())
.children
.compactMap { child in
guard
var codingKey = child.label,
let parsed = child.value as? ArgumentSetProvider
else { return nil }
struct Scaffold: ParsableCommand {
@Argument()
var template: String
}
import ArgumentParser
import Foundation
struct Scaffold: ParsableCommand {
@Argument()
var template: String
func run() throws {
}
@fortmarek
fortmarek / update_store.swift
Created February 28, 2020 16:21
Update store
private func updateStore(of contract: String) {
tezosClient.rateContract(at: contract)
.statusPublisher()
.map(\.storage)
// Do something with the synced storage
}