diff --git a/apps/macos/Sources/ClawdisCLI/main.swift b/apps/macos/Sources/ClawdisCLI/main.swift index 2cae552aa..beba5db5c 100644 --- a/apps/macos/Sources/ClawdisCLI/main.swift +++ b/apps/macos/Sources/ClawdisCLI/main.swift @@ -31,6 +31,9 @@ struct ClawdisCLI { FileHandle.standardOutput.write(json) FileHandle.standardOutput.write(Data([0x0A])) exit(response.ok ? 0 : 1) + } catch CLIError.help { + printHelp() + exit(0) } catch { fputs("clawdis-mac error: \(error)\n", stderr) exit(2) @@ -44,6 +47,9 @@ struct ClawdisCLI { args = Array(args.dropFirst()) switch command { + case "--help", "-h", "help": + throw CLIError.help + case "notify": var title: String? var body: String? @@ -129,6 +135,24 @@ struct ClawdisCLI { // swiftlint:enable cyclomatic_complexity + private static func printHelp() { + let usage = """ + clawdis-mac — talk to the running Clawdis.app XPC service + + Usage: + clawdis-mac notify --title --body [--sound ] + clawdis-mac ensure-permissions [--cap ] [--interactive] + clawdis-mac screenshot [--display-id ] [--window-id ] + clawdis-mac run [--cwd ] [--env KEY=VAL] [--timeout ] [--needs-screen-recording] + clawdis-mac status + clawdis-mac --help + + Returns JSON to stdout: + {"ok":,"message":"...","payload":"..."} + """ + print(usage) + } + private static func send(request: Request) async throws -> Response { let conn = NSXPCConnection(machServiceName: serviceName) let interface = NSXPCInterface(with: ClawdisXPCProtocol.self)