A CLI tool that generate struct or class by simple-syntax.
$ swift-emmet "Pserson: E, C = name: S, age: I, weight: D"
This will generate follows.
struct Pserson: Equatable, Codable {
var name: String
var age: Int
var weight: Double
}
- Decent REPL :)
- Support Apple Silicon
- Distribute binary for Linux
Basic types and protocols are supported aliases (case is ignored).
The following commands are generate same outputs.
$ swift-emmet 'Person: E, C = name:S, age:I, weight:D'
$ swift-emmet 'Person: Equatable, Codable = name:String, age:Int, weight:Double'
struct Person: Equatable, Codable {
var name: String
var age: Int
var weight: Double
}
Alias | Type |
---|---|
S | String |
B | Bool |
I | Int |
L | Long |
F | Float |
D | Double |
U | URL |
Alias | Protocols |
---|---|
E | Equatable |
C | Codable |
# Generate struct
$ swift-emmet 's.Person = l.name:String, v.age:Int, v.weight:Double'
# Generate class (with initializer)
$ swift-emmet 'c.Person = l.name:String, v.age:Int, v.weight:Double'
# Ommit `let` or `var` (`var` will be used)
$ swift-emmet 's.Person = name:String, age:Int, weight:Double'
# Inherit protocol or class
$ swift-emmet 's.Person: Equatable, Codable = l.name:String'
# Any white-space (or not) are allows
$ swift-emmet 's . Person = l . name : String'
$ swift-emmet 's.Person=l.name:String'
If you run swift-emmet
without options, REPL will be started.
$ swift-emmet
--------------------------------------------------------------------
Welcome swift-emmet 🎉
...
--------------------------------------------------------------------
swift-emmet> S.Person = l.name:String # Please input expr
struct Person {
let name: String
}
swift-emmet> exit # Bye
$ swift-emmet --help
Usage: swift-emmet [EXPR] [--version] [--usage]
Generate struct or class from short syntax
Available options:
EXPR Evaluate expression and print
--version Show version
--usage Show detail usage
-h,--help Show this help text
$ brew tap YusukeHosonuma/swift-emmet
$ brew install swift-emmet
$ stack install
$ ~/.local/bin/swift-emmet # or add `~/.local/bin` to PATH environment
Requirements:
$ stack build
$ stack test
You have any ideas or found bugs? Any issue or PR is welcome.
Thanks!