{"id":15065572,"url":"https://github.com/johnsundell/shellout","last_synced_at":"2025-05-15T17:04:42.681Z","repository":{"id":40499363,"uuid":"86999402","full_name":"JohnSundell/ShellOut","owner":"JohnSundell","description":"Easily run shell commands from a Swift script or command line tool","archived":false,"fork":false,"pushed_at":"2024-06-03T00:19:25.000Z","size":59,"stargazers_count":879,"open_issues_count":25,"forks_count":87,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-05-14T04:37:48.624Z","etag":null,"topics":["bash","command-line","marathon","shellout","swift","swift-script"],"latest_commit_sha":null,"homepage":null,"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/JohnSundell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2017-04-02T16:29:41.000Z","updated_at":"2025-05-13T13:30:58.000Z","dependencies_parsed_at":"2024-06-18T17:12:12.079Z","dependency_job_id":null,"html_url":"https://github.com/JohnSundell/ShellOut","commit_stats":{"total_commits":55,"total_committers":14,"mean_commits":"3.9285714285714284","dds":0.5272727272727273,"last_synced_commit":"d3db50b62a86b18f88f5de38cae5f3d80617d555"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnSundell%2FShellOut","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnSundell%2FShellOut/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnSundell%2FShellOut/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnSundell%2FShellOut/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JohnSundell","download_url":"https://codeload.github.com/JohnSundell/ShellOut/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254071614,"owners_count":22009820,"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":["bash","command-line","marathon","shellout","swift","swift-script"],"created_at":"2024-09-25T00:41:54.346Z","updated_at":"2025-05-15T17:04:37.672Z","avatar_url":"https://github.com/JohnSundell.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 🐚 ShellOut\n\nWelcome to ShellOut, a simple package that enables you to easily “shell out” from a Swift script or command line tool.\n\nEven though you can accomplish most of the tasks you need to do in native Swift code, sometimes you need to invoke the power of the command line from a script or tool - and this is exactly what ShellOut makes so simple.\n\n## Usage\n\nJust call `shellOut()`, and specify what command you want to run, along with any arguments you want to pass:\n\n```swift\nlet output = try shellOut(to: \"echo\", arguments: [\"Hello world\"])\nprint(output) // Hello world\n```\n\nYou can also easily run a series of commands at once, optionally at a given path:\n\n```swift\ntry shellOut(to: [\"mkdir NewFolder\", \"echo \\\"Hello again\\\" \u003e NewFolder/File\"], at: \"~/CurrentFolder\")\nlet output = try shellOut(to: \"cat File\", at: \"~/CurrentFolder/NewFolder\")\nprint(output) // Hello again\n```\n\nIn case of an error, ShellOut will automatically read `STDERR` and format it nicely into a typed Swift error:\n\n```swift\ndo {\n    try shellOut(to: \"totally-invalid\")\n} catch {\n    let error = error as! ShellOutError\n    print(error.message) // Prints STDERR\n    print(error.output) // Prints STDOUT\n}\n```\n\n## Pre-defined commands\n\nAnother way to use ShellOut is by executing pre-defined commands, that enable you to easily perform common tasks without having to construct commands using strings. It also ships with a set of such pre-defined commands for common tasks, such as using Git, manipulating the file system and using tools like [Marathon](https://github.com/JohnSundell/Marathon), [CocoaPods](https://cocoapods.org) and [fastlane](https://fastlane.tools).\n\n### Use Git\n\n```swift\ntry shellOut(to: .gitInit())\ntry shellOut(to: .gitClone(url: repositoryURL))\ntry shellOut(to: .gitCommit(message: \"A scripted commit!\"))\ntry shellOut(to: .gitPush())\ntry shellOut(to: .gitPull(remote: \"origin\", branch: \"release\"))\ntry shellOut(to: .gitSubmoduleUpdate())\ntry shellOut(to: .gitCheckout(branch: \"my-feature\"))\n```\n\n### Handle files, folders and symlinks\n\n```swift\ntry shellOut(to: .createFolder(named: \"folder\"))\ntry shellOut(to: .createFile(named: \"file\", contents: \"Hello world\"))\ntry shellOut(to: .moveFile(from: \"path/a\", to: \"path/b\"))\ntry shellOut(to: .copyFile(from: \"path/a\", to: \"path/b\"))\ntry shellOut(to: .openFile(at: \"Project.xcodeproj\"))\ntry shellOut(to: .readFile(at: \"Podfile\"))\ntry shellOut(to: .removeFile(from: \"path/a\"))\ntry shellOut(to: .createSymlink(to: \"target\", at: \"link\"))\ntry shellOut(to: .expandSymlink(at: \"link\"))\n```\n\n*For a more powerful and object-oriented way to handle Files \u0026 Folders in Swift, check out [Files](https://github.com/JohnSundell/Files)*\n\n### Use [Marathon](https://github.com/JohnSundell/Marathon)\n\n```swift\ntry shellOut(to: .runMarathonScript(at: \"~/scripts/MyScript\", arguments: [\"One\", \"Two\"]))\ntry shellOut(to: .updateMarathonPackages())\n```\n\n### Use [The Swift Package Manager](https://github.com/apple/swift-package-manager)\n\n```swift\ntry shellOut(to: .createSwiftPackage(withType: .executable))\ntry shellOut(to: .updateSwiftPackages())\ntry shellOut(to: .generateSwiftPackageXcodeProject())\ntry shellOut(to: .buildSwiftPackage())\ntry shellOut(to: .testSwiftPackage())\n```\n\n### Use [fastlane](https://fastlane.tools)\n\n```swift\ntry shellOut(to: .runFastlane(usingLane: \"appstore\"))\n```\n\n### Use [CocoaPods](https://cocoapods.org)\n\n```swift\ntry shellOut(to: .updateCocoaPods())\ntry shellOut(to: .installCocoaPods())\n```\n\nDon't see what you're looking for in the list above? You can easily define your own commands using `ShellOutCommand`. If you've made a command you think should be included among the built-in ones, feel free to [open a PR](https://github.com/JohnSundell/ShellOut/pull/new/master)!\n\n## Installation\n\n### For scripts\n\n- Install [Marathon](https://github.com/johnsundell/marathon).\n- Add ShellOut to Marathon using `$ marathon add https://github.com/JohnSundell/ShellOut.git`.\n- Alternatively, add `https://github.com/JohnSundell/ShellOut.git` to your `Marathonfile`.\n- Write your script, then run it using `$ marathon run yourScript.swift`.\n\n### For command line tools\n\n- Add `.package(url: \"https://github.com/JohnSundell/ShellOut.git\", from: \"2.0.0\")` to your `Package.swift` file's `dependencies`.\n- Update your packages using `$ swift package update`.\n\n## Help, feedback or suggestions?\n\n- [Open an issue](https://github.com/JohnSundell/ShellOut/issues/new) if you need help, if you found a bug, or if you want to discuss a feature request.\n- [Open a PR](https://github.com/JohnSundell/ShellOut/pull/new/master) if you want to make some change to ShellOut.\n- Contact [@johnsundell on Twitter](https://twitter.com/johnsundell) for discussions, news \u0026 announcements about ShellOut \u0026 other projects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsundell%2Fshellout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnsundell%2Fshellout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsundell%2Fshellout/lists"}