{"id":15672622,"url":"https://github.com/samuelmeuli/swift-exec","last_synced_at":"2025-10-29T16:37:41.328Z","repository":{"id":95954127,"uuid":"249391149","full_name":"samuelmeuli/swift-exec","owner":"samuelmeuli","description":":rocket: Simple process execution with Swift","archived":false,"fork":false,"pushed_at":"2020-04-29T13:06:21.000Z","size":17,"stargazers_count":16,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-06T21:48:16.746Z","etag":null,"topics":["command-execution","shell-execution","swift","swift-library","swift-package"],"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/samuelmeuli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2020-03-23T09:46:36.000Z","updated_at":"2023-05-21T06:33:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"59ac7f17-8f59-4d3d-8c98-45460a8f1923","html_url":"https://github.com/samuelmeuli/swift-exec","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/samuelmeuli/swift-exec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmeuli%2Fswift-exec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmeuli%2Fswift-exec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmeuli%2Fswift-exec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmeuli%2Fswift-exec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuelmeuli","download_url":"https://codeload.github.com/samuelmeuli/swift-exec/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmeuli%2Fswift-exec/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268273009,"owners_count":24223790,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["command-execution","shell-execution","swift","swift-library","swift-package"],"created_at":"2024-10-03T15:29:01.220Z","updated_at":"2025-10-29T16:37:41.215Z","avatar_url":"https://github.com/samuelmeuli.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftExec\n\n**Simple process execution with Swift**\n\n## Install\n\nTo use SwiftExec with the [Swift Package Manager](https://swift.org/package-manager), add the following lines to your `Package.swift` file:\n\n```swift\nlet package = Package(\n\tdependencies: [\n\t\t.package(url: \"https://github.com/samuelmeuli/swift-exec\", \"0.1.0\" ..\u003c \"0.2.0\"),\n\t],\n\ttargets: [\n\t\t.target(\n\t\t\tname: \"MyProject\",\n\t\t\tdependencies: [\n\t\t\t\t\"SwiftExec\",\n\t\t\t]\n\t\t),\n\t]\n)\n```\n\n## Examples\n\n### Simple command\n\n```swift\nimport SwiftExec\n\ndo {\n\tlet result = try exec(program: \"/bin/echo\", arguments: [\"hello\", \"world\"])\n\tprint(result.stdout!)\n} catch {\n\tprint(\"Command failed\")\n}\n```\n\n### Advanced output handling\n\n```swift\nimport SwiftExec\n\nvar result: ExecResult\ndo {\n\tresult = try exec(program: \"/usr/bin/git\", arguments: [\"status\"])\n} catch {\n\tlet error = error as! ExecError\n\tresult = error.execResult\n}\n\nprint(result.exitCode!)\nprint(result.stdout!)\nprint(result.stderr!)\n```\n\n### Bash command\n\n```swift\nimport SwiftExec\n\nvar result: ExecResult\ndo {\n\tresult = try execBash(\"git status\")\n} catch {\n\tlet error = error as! ExecError\n\tresult = error.execResult\n}\n\nprint(result.exitCode!)\nprint(result.stdout!)\nprint(result.stderr!)\n```\n\n## API\n\n### Functions\n\nSwiftExec provides the following functions:\n\n- **`exec(program, arguments?, options?) -\u003e ExecResult`** – Invokes the specified program in a new process using the provided arguments\n  - `program: String` – Path to the program which should be executed (e.g. `\"/bin/ls\"`)\n  - `arguments: [String] = []` – Arguments to pass to the program\n  - `options: ExecOptions = ExecOptions()` – See [options](#options)\n- **`execBash(command, options?) -\u003e ExecResult`** – Runs the provided command using Bash. The function calls `exec` internally\n  - `command: String` – Command which should be executed using Bash (e.g. `\"echo 'hello world'\"`)\n  - `options: ExecOptions = ExecOptions()` – See [options](#options)\n\n### Output\n\nThe `exec` function returns an instance of **`ExecResult`**, which contains the following fields:\n\n- **`failed: Bool`** – Status of the executed command. It is considered to be failed if either the execution failed or the process returned a non-zero exit code\n- **`message: String?`** – Error message for failed commands. Contains `stderr` if a non-zero exit code is the reason for the failure\n- **`exitCode: Int32?`** – Exit code of the process that was executed\n- **`stdout: String?`** – `stout` of the process that was executed\n- **`stderr: String?`** – `stderr` of the process that was executed\n\n### Options\n\nThe `exec` function behavior can be configured by passing in an instance of **`ExecOptions`**, with the following optional fields:\n\n- **`cwd: URL?`** – Current working directory of the process\n- **`stripFinalNewline: Bool = true`** – Whether to remove the final newline character from output\n\n## Contributing\n\nSuggestions and contributions are always welcome! Please discuss larger changes via issue before submitting a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelmeuli%2Fswift-exec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelmeuli%2Fswift-exec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelmeuli%2Fswift-exec/lists"}