• This repository has been archived on 04/Jan/2020
  • Stars
    star
    1,863
  • Rank 24,874 (Top 0.5 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[DEPRECATED] Marathon makes it easy to write, run and manage your Swift scripts πŸƒ

⚠️ DEPRECATED: Marathon is now deprecated in favor of using the Swift Package Manager directly. It's recommended to migrate your scripts as soon as possible, since future Xcode/macOS versions may break compatibility. See this issue for more info.

Marathon

Travis status Swift Package Manager Twitter: @johnsundell

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 https://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

🌍 Run remote scripts directly from a Git repository...

$ marathon run https://github.com/johnsundell/testdrive.git

...using only a GitHub username & repository name:

$ marathon run johnsundell/testdrive

πŸ’» Install scripts as binaries and run them independently from anywhere...

$ marathon install helloWorld
$ helloWorld
> Hello world

...you can even install remote scripts (+ their dependencies) from a URL:

$ marathon install https://raw.githubusercontent.com/JohnSundell/Marathon-Examples/master/AddSuffix/addSuffix.swift
$ cd myImages
$ addSuffix "@2x"
> Added suffix "@2x" to 15 files

...or from a GitHub repository:

$ marathon install johnsundell/testdrive
$ testdrive

πŸ‘ͺ Share your scripts with your team and automatically install their dependencies...

import Files // marathon:https://github.com/JohnSundell/Files.git

print(Folder.current.path)

...or specify your dependencies using a Marathonfile:

$ echo "https://github.com/JohnSundell/Files.git" > Marathonfile

Installing

On macOS

Using Make (recommended):

$ git clone https://github.com/JohnSundell/Marathon.git
$ cd Marathon
$ make

Using the Swift Package Manager:

$ git clone https://github.com/JohnSundell/Marathon.git
$ cd Marathon
$ swift build -c release -Xswiftc -static-stdlib
$ cp -f .build/release/Marathon /usr/local/bin/marathon

Using Mint:

$ mint install JohnSundell/Marathon

Using Homebrew (not recommended, due to slow update cycle):

brew install marathon-swift

On Linux

$ git clone https://github.com/JohnSundell/Marathon.git
$ cd Marathon
$ swift build -c release
$ cp -f .build/release/Marathon /usr/local/bin/marathon

If you encounter a permissions failure while installing, you may need to prepend sudo to the commands. To update Marathon, simply repeat any of the above two series of commands, except cloning the repo.

Requirements

Marathon requires the following to be installed on your system:

  • Swift 4.1 or later (bundled with Xcode 9.3 or later)
  • Git
  • Xcode (if you want to edit scripts using it)

Examples

Check out this repository for a few example Swift scripts that you can run using Marathon.

Specifying dependencies inline

Scripting usually involves using 3rd party frameworks to get your job done, and Marathon provides an easy way to define such dependencies right when you are importing them in your script, using a simple comment syntax:

import Files // marathon:https://github.com/JohnSundell/Files.git
import Unbox // marathon:https://github.com/JohnSundell/Unbox.git

Specifying your dependencies ensures that they will always be installed by Marathon before your script is run, edited or installed - making it super easy to share scripts with your friends, team or the wider community. All you have to do is share the script file, and Marathon takes care of the rest!

Using a Marathonfile

If you prefer to keep your dependency declarations separate, 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 either:

  • The URL to a git repository of a local or remote package to install before running your script.
  • The path to another script that should be linked to your script before running it.

Here is an example of a Marathonfile:

https://github.com/JohnSundell/Files.git
https://github.com/JohnSundell/Unbox.git
https://github.com/JohnSundell/Wrap.git
~/packages/MyPackage
otherScript.swift

Shell autocomplete

Marathon includes autocomplete for the zsh and fish shells (PRs adding support for other shells is more than welcome!). To enable it, do the following:

  • zsh:

    • Add the line fpath=(~/.marathon/ShellAutocomplete/zsh $fpath) to your ~/.zshrc file.
    • Add the line autoload -Uz compinit && compinit -i to your ~/.zshrc file if it doesn't already contain it.
    • Restart your terminal.
  • fish:

    • cp -f ~/.marathon/ShellAutocomplete/fish/marathon.fish ~/.config/fish/completions

You can now type marathon r and have it be autocompleted to marathon run πŸŽ‰

Help, feedback or suggestions?

  • Run $ marathon help to display help for the tool itself or for any specific command.
  • Append --verbose to any command to make Marathon output everything it's doing, for debugging purposes.
  • 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.

More Repositories

1

Publish

A static site generator for Swift developers
Swift
4,840
star
2

SwiftTips

A collection of Swift tips & tricks that I've shared on Twitter
3,971
star
3

Files

A nicer way to handle files & folders in Swift
Swift
2,456
star
4

Ink

A fast and flexible Markdown parser written in Swift.
Swift
2,377
star
5

Plot

A DSL for writing type-safe HTML, XML and RSS in Swift.
Swift
1,979
star
6

Unbox

[Deprecated] The easy to use Swift JSON decoder
Swift
1,956
star
7

ImagineEngine

A project to create a blazingly fast Swift game engine that is a joy to use πŸš€
Swift
1,825
star
8

SwiftPlate

Easily generate cross platform Swift framework projects from the command line
Swift
1,766
star
9

Splash

A fast, lightweight and flexible Swift syntax highlighter for blogs, tools and fun!
Swift
1,758
star
10

TestDrive

Quickly try out any Swift pod or framework in a playground
Swift
1,597
star
11

Codextended

Extensions giving Swift's Codable API type inference super powers πŸ¦Έβ€β™‚οΈπŸ¦Ήβ€β™€οΈ
Swift
1,495
star
12

ShellOut

Easily run shell commands from a Swift script or command line tool
Swift
836
star
13

Wrap

[DEPRECATED] The easy to use Swift JSON encoder
Swift
732
star
14

CollectionConcurrencyKit

Async and concurrent versions of Swift’s forEach, map, flatMap, and compactMap APIs.
Swift
730
star
15

Sweep

Fast and powerful Swift string scanning made simple
Swift
531
star
16

Playground

Instantly create Swift playgrounds from the command line
Swift
439
star
17

Require

Require optional values to be non-nil, or crash gracefully
Swift
414
star
18

XcodeTheme

My Xcode theme - Sundell's Colors
Swift
408
star
19

AsyncCompatibilityKit

iOS 13-compatible backports of commonly used async/await-based system APIs that are only available from iOS 15 by default.
Swift
378
star
20

Shapeshift

Quickly convert a folder containing Swift files into an iPad-compatible Playground
Swift
338
star
21

Identity

πŸ†” Type-safe identifiers in Swift
Swift
298
star
22

SwiftBySundell

Code samples from the Swift by Sundell website & podcast
Swift
289
star
23

SwiftScripting

A list of Swift scripting tools, frameworks & examples
235
star
24

SuperSpriteKit

Extensions to Apple's SpriteKit game engine
Objective-C
224
star
25

Flow

Operation Oriented Programming in Swift
Swift
217
star
26

Xgen

A Swift package for generating Xcode workspaces & playgrounds
Swift
189
star
27

IndieSupportWeeks

A two-week effort to help support indie developers shipping apps on Apple's platforms who have been financially impacted by the COVID-19 pandemic.
182
star
28

CGOperators

Easily manipulate CGPoints, CGSizes and CGVectors using math operators
Swift
148
star
29

Animate

Declarative UIView animations without nested closures
Swift
129
star
30

SplashPublishPlugin

A Splash plugin for the Publish static site generator
Swift
92
star
31

Assert

A collection of convenient assertions for Swift testing
Swift
69
star
32

UITestingExample

Example code from my blog post about UI testing
Swift
67
star
33

Marathon-Examples

A collection of example Swift scripts that can easily be run using Marathon
Swift
55
star
34

Releases

A Swift package for resolving released versions from a Git repository
Swift
51
star
35

BlockSnippets

Xcode snippets that are very handy when working with blocks in various contexts
51
star
36

PlotPlayground

A Swift playground that comes pre-loaded with Plot, that can be used to explore the new component API.
Swift
49
star
37

SwiftKit

A collection of Swift utilities that I share across my Swift-based projects
Swift
38
star
38

UnitTestingWorkshop

Project used during my workshop "Getting started with unit testing in Swift"
Swift
36
star
39

JSUpdateLookup

A lightweight, easy to use Objective-C class to check if your iOS app has an update available
Objective-C
28
star
40

SwiftAveiro

Skeleton project for my Swift Aveiro workshop "Everyone is an API designer"
Swift
15
star
41

CloudKitChat

A demo chat application powered by CloudKit
Objective-C
14
star
42

swiftbysundell-beta-feedback

Submit your feedback on the Swift by Sundell 2.0 beta
9
star
43

JSGeometry

A set of utility functions that enables easy one-line manipulation of CoreGraphics geometry structs like CGPoint, CGSize & CGRect.
Objective-C
6
star
44

JSAutoCopy

An Objective-C category that enables automatic copying of any object
Objective-C
4
star
45

UnboxDemoPlayground

A Swift Playground that comes setup with Unbox & Wrap, used in my CocoaHeads Stockholm presentation
Swift
3
star
46

JSAutoEncodedObject

Automatically encode or decode any Objective-C object
Objective-C
3
star
47

JSLocalization

An Objective-C class that enables dynamic localization of an iOS app.
Objective-C
3
star
48

MarathonTestScriptWithDependencies

A test script with dependencies - used for Marathon's tests
Swift
2
star
49

JSObservableObject

Easily add protocol-based observation to any Objective-C class
Objective-C
2
star
50

MarathonTestScript

A Swift script that's used in Marathon's tests
Swift
1
star
51

MarathonTestPackage

A Swift package that's used in Marathon's tests
Swift
1
star