Skip to content

Instantly share code, notes, and snippets.

View fortmarek's full-sized avatar
💭
🙂

Marek Fořt fortmarek

💭
🙂
View GitHub Profile
@fortmarek
fortmarek / authentication.md
Created December 3, 2025 08:43
Tuist authentication

Tuist CLI Authentication Flow

sequenceDiagram
    participant User
    participant CLI as Tuist CLI
    participant Browser
    participant Server as Tuist Server
    participant Storage as Storage
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 {
}