{"id":18473414,"url":"https://github.com/0xopenbytes/o","last_synced_at":"2025-04-08T12:31:51.893Z","repository":{"id":63901295,"uuid":"470812284","full_name":"0xOpenBytes/o","owner":"0xOpenBytes","description":"Output and Input for File, URL, and Console ","archived":false,"fork":false,"pushed_at":"2023-03-25T18:52:08.000Z","size":29,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-16T16:02:18.697Z","etag":null,"topics":["console","file","input","ios","output","swift","url"],"latest_commit_sha":null,"homepage":"https://0xopenbytes.github.io/o/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xOpenBytes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-17T01:50:17.000Z","updated_at":"2024-01-07T20:39:40.000Z","dependencies_parsed_at":"2024-11-06T10:43:25.271Z","dependency_job_id":null,"html_url":"https://github.com/0xOpenBytes/o","commit_stats":{"total_commits":26,"total_committers":2,"mean_commits":13.0,"dds":0.07692307692307687,"last_synced_commit":"cfcf914e21793dc6cb4d034d602564c682f1eea7"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xOpenBytes%2Fo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xOpenBytes%2Fo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xOpenBytes%2Fo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xOpenBytes%2Fo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xOpenBytes","download_url":"https://codeload.github.com/0xOpenBytes/o/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247842662,"owners_count":21005321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["console","file","input","ios","output","swift","url"],"created_at":"2024-11-06T10:24:46.564Z","updated_at":"2025-04-08T12:31:51.581Z","avatar_url":"https://github.com/0xOpenBytes.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n   \u003cimg src=\"https://openbytes.dev/assets/projects/images/openbytes-o.png\" alt=\"Icon representing the OpenBytes o project.\" width=\"35%\"/\u003e\n   \u003ch1\u003eo\u003c/h1\u003e\n   \u003ch3\u003eOutput and Input\u003c/h3\u003e\n   \u003ca href=\"https://github.com/0xOpenBytes/o/blob/main/LICENSE\"\u003e\n     \u003cimg src=\"https://img.shields.io/badge/license-MIT-blue\" alt=\"MIT License\"/\u003e\n   \u003c/a\u003e\n   \u003cimg src=\"https://img.shields.io/github/v/release/0xOpenBytes/o\"/\u003e\n   \u003ca href=\"https://discord.gg/HUmaDXVsW7\"\u003e\n     \u003cimg src=\"https://img.shields.io/discord/933406727150391376\" alt=\"Community Chat\"/\u003e\n   \u003c/a\u003e\n \u003c/div\u003e\n\n## What is `o`?\n\n`o` is a simple framework to output to a file, url, the console, or even register notification using UserNotifications. `o` can also get input from a file, url, or console.\n\n## Where can `o` be used?\n\nCurrently, `o` can be used on macOS, iOS, and watchOS. \n\n## Examples\n\n### o.console\n```swift\no.console.out(\"Value to print: \", terminator: \"\") //    (oTests/oTests.swift@7) [testExample()]: Value to print:\no.console.out(o.console.in()) // Type in \"???\";         (oTests/oTests.swift@8) [testExample()]: Optional(\"???\")\n```\n\n### o.file\n```swift\nlet fileContents = 4\nlet folderPath = \"./TestFolder\"\nlet filename = \"SomeNumber\"\n\ntry o.file.createDirectory(path: folderPath)\n\n// Write the value 4, an Int, to a file named `filename` in the `folderPath` directory. Files using o.file are base64Encoded by default.\ntry o.file.out(fileContents, path: folderPath, filename: filename, base64Encoded: false)\n\n// Asserts\nXCTAssertEqual(try o.file.in(path: folderPath, filename: filename), 4)\n\n// Delete the File\ntry o.file.delete(path: folderPath, filename: filename)\n\n// Assert deletion\nXCTAssertThrowsError(try o.file.in(path: folderPath, filename: filename) as Int)\n```\n\n### o.url\n```swift\nstruct Post: Codable {\n    let userId: Int\n    let id: Int\n    let title: String\n    let body: String\n}\n\n// GET Request\n\nlet (data, response) = try await o.url.get(\n    url: URL(string: \"api/posts\")!\n)\n\n// POST Request\n\nlet post = Post(userId: 1, id: 1, title: \"First!\", body: \"\")\n\nlet (_, response) = try await o.url.post(\n    url: URL(string: \"api/posts/\\(post.id)\")!,\n    body: try? JSONEncoder().encode(post)\n)\n\nprint(response)\n```\n\n### o.notification\n```swift\n// Request Notification Authorization \no.notification.requestAuthorization()\n\n// Set UNUserNotificationCenter.current's delegate to `o.notification.delegate`\no.notification.registerDelegate()\n\n// Schedule a Notification\no.notification.post(\n    title: \"Hello!\",\n    subtitle: \"o.notification\",\n    body: \"Woo Hoo!\",\n    trigger: UNTimeIntervalNotificationTrigger(\n        timeInterval: 3,\n        repeats: false\n    )\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xopenbytes%2Fo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xopenbytes%2Fo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xopenbytes%2Fo/lists"}