You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import AppKit
structColor:Encodable{letred:Floatletblue:Floatletgreen:Floatletalpha:FloatletcolorSpace:String}structColorPickerCLI{staticfunc pickColor()async->Color?{letcolorSampler=NSColorSampler()
guard let color =await colorSampler.sample()?.usingColorSpace(.displayP3)else{returnnil}returnColor(
red:Float(color.redComponent),
blue:Float(color.blueComponent),
green:Float(color.greenComponent),
alpha:Float(color.alphaComponent),
colorSpace:"p3")}staticfunc run(){// Run the asynchronous color picking in a TaskTask{
if let color =awaitpickColor(){print("Color picked:")print("Red: \(color.red)")print("Green: \(color.green)")print("Blue: \(color.blue)")print("Alpha: \(color.alpha)")print("Color Space: \(color.colorSpace)")// Exit the program after printing the color informationexit(0)}else{print("No color picked or an error occurred.")}}// Keep the program running to allow async tasks to finishRunLoop.current.run()}}ColorPickerCLI.run()
The text was updated successfully, but these errors were encountered:
Sample CLI swift code, get value from stdout.
The text was updated successfully, but these errors were encountered: