Swiftpack.co - Package - apleshkov/saber

Saber

Dependency Injection (DI) / Inversion of Control (IoC) command line tool for Swift based on code generation.

Saber requires no frameworks, just parses sources (via SourceKitten), finds annotations and generates containers.

Documentation

Please, see wiki and examples.

Installation

Building saber on macOS requires Xcode 9.3+ / Swift 4.1 and Swift Package Manager.

Development

Xcode: clone, run make xcodeproj and then open a generated Saber.xcodeproj. Use make docker_linux_test to test on Linux inside a docker container.

Linux: make clean, make build and make test

Homebrew

TODO

Make

Clone & run make install in the root directory of this project.

Run make uninstall to uninstall.

Usage

$ saber help
Available commands:

   help        Display general or command-specific help
   sources     Generate containers from sources
   version     Print current version
   xcodeproj   Generate containers from Xcode project

sources

Saber traverses swift-files --from recursively and generates container classes to --out.

Example: saber --workDir . --from Sources --out Sources/Saber

$ saber help sources
Generate containers from sources

[--workDir (string)]
	Working directory (optional)

[--from (string)]
	Directory with sources (is relative to --workDir if any)

[--out (string)]
	Output directory (is relative to --workDir if any)

[--config (string)]
	Path to *.yml or YAML text (optional)

[--log (string)]
	Could be 'info' (by default) or 'debug' (optional)

xcodeproj (on macOS only)

Saber parses Xcode project at --path, traverses enumerated --targets and generates container classes to --out. The main difference from the sources command is an ability to work with Swift modules.

Example: saber --workDir . --path MyProject.xcodeproj --targets Target1,Target2 --out Sources/Saber

$ saber help xcodeproj
Generate containers from Xcode project

[--workDir (string)]
	Working directory (optional)

[--path (string)]
	Path to *.xcodeproj (is relative to --workDir if any)

[--targets (string)]
	Comma-separated list of project target names

[--out (string)]
	Output directory (is relative to --workDir if any)

[--config (string)]
	Path to *.yml or YAML text (optional)

[--log (string)]
	Could be 'info' (by default) or 'debug' (optional)

Configuration

Provide it via --config as text or file:

# Access level for generated classes (internal by default)
accessLevel: internal # public, open, ...
# Identation for generated files (4 spaces by default)
indentation:
    type: space # or tab
    size: 4
# Lazy typealias (see wiki; none by default)
lazyTypealias: LazyInjection

License

MIT

Github

link
Stars: 8
Help us keep the lights on

Used By

Total: 0