Welcome to Marathon, a command line tool that makes it easy to write, run and manage your Swift scripts. It's powered by the Swift Package Manager and requires no modification to your existing scripts or dependency packages.
Features
Create scripts
$ marathon create helloWorld "import Foundation; print(\"Hello world\")"
复制代码
Run scripts
$ marathon run helloWorld
> Hello world
复制代码
Hassle free dependency management. Simply add a package...
$ marathon add git@github.com:JohnSundell/Files.git
复制代码
...and use it without any additional work
import Files
for file in try Folder(path: "MyFolder").files {
print(file.name)
}复制代码
Update all of your scripting dependencies with a single call
$ marathon update
复制代码
Edit, run & debug your scripts using Xcode...
$ marathon edit helloWorld
复制代码
...or in your favorite text editor
$ marathon edit helloWorld -no-xcode
复制代码
Share your scripts with your team and automatically install their
dependencies:
$ echo "git@github.com:JohnSundell/Files.git" > Marathonfile
$ marathon run mySharedScript
复制代码
Installing
Using Make:
$ git clone git@github.com:JohnSundell/Marathon.git
$ cd Marathon
$ make
复制代码
Using the Swift Package Manager:
$ git clone git@github.com:JohnSundell/Marathon.git
$ cd Marathon
$ swift build -c release -Xswiftc -static-stdlib
$ cp -f .build/release/Marathon /usr/local/bin/marathon
复制代码
Examples
Check out this repository for a few example Swift scripts that you can run using Marathon.
Using a Marathonfile
To easily be able to define depenencies for a script in a declarative way, you can create a Marathonfile
in the same folder as your script. This file is simply a new line separated list of URLs pointing
to packages that should be installed before running the script. By doing this you can ensure that the required dependencies will be installed when sharing your script with team members, friends or the wider community.
Here is an example of a Marathonfile
:
git@github.com:JohnSundell/Files.git
git@github.com:JohnSundell/Unbox.git
git@github.com:JohnSundell/Wrap.git
复制代码
Help, feedback or suggestions?
- Run
$ marathon help
to display help for the tool itself or for any specific command. - Open an issue if you need help, if you found a bug, or if you want to discuss a feature request.
- Open a PR if you want to make some change to Marathon.
- Contact @johnsundell on Twitter for discussions, news & announcements about Marathon.