38 lines · 1.3 KB · Swift
RawDownload
import Foundation public struct StepFunSettingsReader: Sendable {    public static let usernameEnvironmentKey = "STEPFUN_USERNAME"    public static let passwordEnvironmentKey = "STEPFUN_PASSWORD"    public static let tokenEnvironmentKey = "STEPFUN_TOKEN"     public static func username(        environment: [String: String] = ProcessInfo.processInfo.environment) -> String?    {        self.cleaned(environment[self.usernameEnvironmentKey])    }     public static func password(        environment: [String: String] = ProcessInfo.processInfo.environment) -> String?    {        self.cleaned(environment[self.passwordEnvironmentKey])    }     public static func token(        environment: [String: String] = ProcessInfo.processInfo.environment) -> String?    {        self.cleaned(environment[self.tokenEnvironmentKey])    }     private static func cleaned(_ raw: String?) -> String? {        guard var value = raw?.trimmingCharacters(in: .whitespacesAndNewlines), !value.isEmpty else {            return nil        }        if (value.hasPrefix("\"") && value.hasSuffix("\"")) ||            (value.hasPrefix("'") && value.hasSuffix("'"))        {            value = String(value.dropFirst().dropLast())        }        value = value.trimmingCharacters(in: .whitespacesAndNewlines)        return value.isEmpty ? nil : value    }}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t