Contents

omochi/gysb

gysb is Generate Your Swifty Boilerplate.

other examples

See Examples and Tests.

docs

command line help

$ swift run gysb --help
Usage: .build/x86_64-apple-macosx10.10/debug/gysb [mode] [flags] paths...

# mode
    --help: print help
    --parse: print AST
    --compile: print compiled Swift
    --render: render template (default)

# flags
    --write: write output on same directory (extension removed)
    --source-dirs: paths means directory and search *.gysb (automatically enable `--write`)

syntax

  • %%: escaped %
  • $$: escaped $
  • %{ <swift-code> }%: code block
  • % <swift-code> <newline>: code line
  • ${ <swift-code> }: code substitution

gysb.json

You can use more useful feature of gysb by using gysb.json. gysb command search gysb.json for each gysb template files within same or ancestor directory.

gysb.json features

  • local library script inclusion. See example in Examples/simple_include.
  • external library via SwiftPM package. See example in Examples/yaml.

install

There are some install approachs.

  1. install from homebrew
  2. build yourself and set path

homebrew

$ brew install omochi/taps/gysb

build yourself

Checkout repository.

$ git clone https://github.com/omochi/gysb.git
$ cd gysb

Build.

$ swift build

Get path.

$ echo $(pwd)/.build/debug
/Users/omochi/github/omochi/gysb/.build/debug

Set path.

$ vim ~/.bash_profile

development

This repository is maintained by SwiftPM.

Use xcodeproj and work with it.

$ swift package generate-xcodeproj
$ open gysb.xcodeproj

Package Metadata

Repository: omochi/gysb

Default branch: master

README: README.md