{"id":20544170,"url":"https://github.com/flintprocessor/work","last_synced_at":"2025-03-06T04:47:40.034Z","repository":{"id":63910102,"uuid":"134751828","full_name":"flintprocessor/Work","owner":"flintprocessor","description":"Execute shell command and get output. Simple and robust.","archived":false,"fork":false,"pushed_at":"2018-07-01T06:40:55.000Z","size":36,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-16T21:23:20.017Z","etag":null,"topics":["cli","process","shellscript","swift","task"],"latest_commit_sha":null,"homepage":"","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/flintprocessor.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}},"created_at":"2018-05-24T18:04:47.000Z","updated_at":"2020-12-06T12:21:51.000Z","dependencies_parsed_at":"2022-11-29T07:07:56.206Z","dependency_job_id":null,"html_url":"https://github.com/flintprocessor/Work","commit_stats":null,"previous_names":["flintbox/work"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flintprocessor%2FWork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flintprocessor%2FWork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flintprocessor%2FWork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flintprocessor%2FWork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flintprocessor","download_url":"https://codeload.github.com/flintprocessor/Work/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242150752,"owners_count":20080006,"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":["cli","process","shellscript","swift","task"],"created_at":"2024-11-16T01:42:49.814Z","updated_at":"2025-03-06T04:47:40.003Z","avatar_url":"https://github.com/flintprocessor.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\u003cimg src=\"/Assets/logo.svg\" width=\"250\" /\u003e\u003c/div\u003e\n\u003ch1 align=\"center\"\u003e\n  \u003cb\u003eWork\u003c/b\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://github.com/flintbox/Work/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/release/flintbox/Work.svg\" alt=\"GitHub release\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://swift.org/package-manager\"\u003e\u003cimg src=\"https://img.shields.io/badge/Swift%20PM-compatible-orange.svg\" alt=\"Swift Package Manager\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/flintbox/Work/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/mashape/apistatus.svg\" alt=\"license\" /\u003e\u003c/a\u003e\n\u003c/h1\u003e\n\n*Execute shell command and get output. **Simple** and **robust**.*\n\n**Table of Contents**\n- [Installation](#installation)\n- [Work](#work)\n- [Example](#example)\n  - [Synchronous](#synchronous)\n  - [Asynchronous](#asynchronous)\n- [Contribute](#contribute)\n\n## Installation\n\nAdd Work to `Package.swift`.\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/flintbox/Work\", from: \"0.1.0\")\n]\n```\n\n## Work\n\n[Work](https://github.com/flintbox/Work/blob/master/Sources/Work/Work.swift) is subclass of [Operation](https://developer.apple.com/documentation/foundation/operation) wrapping [Process](https://developer.apple.com/documentation/foundation/process) object.\n\n## Example\n\n### Synchronous\n\n#### [main.swift](https://github.com/flintbox/Work/blob/master/Sources/work-sync/main.swift)\n\n```swift\nimport Foundation\nimport Work\n\n// Create shell commands.\nlet echo1 = Work(\n    command: \"echo 1-1; sleep 1; echo 1-2; sleep 1; echo 1-3\",\n    standardOutputHandler: { output in\n        print(\"echo1 says: \\(output)\")\n    }\n)\nlet echo2 = Work(command: \"echo 2-1; sleep 1; echo 2-2; sleep 1; echo 2-3\")\n\n// Start them synchronously.\necho1.start()\necho2.start()\n\n// Print standard output of echo2.\nprint(echo2.standardOutput)\n```\n\n#### Output\n\n```shell\necho1 says: 1-1\necho1 says: 1-2\necho1 says: 1-3\n2-1\n2-2\n2-3\n```\n\n### Asynchronous\n\n#### [main.swift](https://github.com/flintbox/Work/blob/master/Sources/work-async/main.swift)\n\n```swift\nimport Foundation\nimport Work\n\n// Create shell commands.\nlet echo1 = Work(command: \"echo 1-1; sleep 1; echo 1-2; sleep 1; echo 1-3\")\necho1.standardOutputHandler = { output in\n    print(\"echo1 says: \\(output)\")\n}\necho1.completion = { result in\n    switch result {\n    case .success(_):\n        print(\"echo1 success\")\n    case .failure(_, _):\n        print(\"echo1 failure\")\n    }\n}\n\nlet echo2 = Work(\n    command: \"echo 2-1; sleep 1; echo 2-2; sleep 3; echo 2-3\",\n    standardOutputHandler: { output in\n        print(\"echo2 says: \\(output)\")\n    }, completion: { result in\n        switch result {\n        case .success(_):\n            print(\"echo2 success\")\n        case .failure(_, _):\n            print(\"echo2 failure\")\n        }\n    }\n)\n\n// Start them asynchronously.\nOperationQueue().addOperations([echo1, echo2], waitUntilFinished: true)\n```\n\n#### Output\n\n```shell\necho2 says: 2-1\necho1 says: 1-1\necho2 says: 2-2\necho1 says: 1-2\necho1 says: 1-3\necho1 success\necho2 says: 2-3\necho2 success\n```\n\n## Contribute\n\nIf you have good idea or suggestion? Please, don't hesitate to open a pull request or send me an [email](mailto:contact@jasonnam.com).\n\nHope you enjoy building command line tool with Work!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflintprocessor%2Fwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflintprocessor%2Fwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflintprocessor%2Fwork/lists"}