Skip to content
This repository was archived by the owner on Mar 1, 2020. It is now read-only.

Commit e73253c

Browse files
committed
Switch to Commander
Closes #1
1 parent d43b9ac commit e73253c

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ platform :osx, '10.10'
33
use_frameworks!
44
plugin 'cocoapods-rome'
55

6+
pod 'Commander', :git => 'https://github.com/kylef/Commander'
67
pod 'PathKit', '0.4.0-beta.1'
78
pod 'Stencil', :git => 'https://github.com/kylef/Stencil', :branch => 'swift-2.0'
89

Podfile.lock

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
PODS:
2+
- Commander (0.1.0)
23
- PathKit (0.4.0-beta.1)
34
- Stencil (0.2.0):
45
- PathKit (~> 0.4.0-beta.1)
56

67
DEPENDENCIES:
8+
- Commander (from `https://github.com/kylef/Commander`)
79
- PathKit (= 0.4.0-beta.1)
810
- Stencil (from `https://github.com/kylef/Stencil`, branch `swift-2.0`)
911

1012
EXTERNAL SOURCES:
13+
Commander:
14+
:git: https://github.com/kylef/Commander
1115
Stencil:
1216
:branch: swift-2.0
1317
:git: https://github.com/kylef/Stencil
1418

1519
CHECKOUT OPTIONS:
20+
Commander:
21+
:commit: 12d1c1a104e2067f2cf7dc19a1106fbbfcc95e00
22+
:git: https://github.com/kylef/Commander
1623
Stencil:
1724
:commit: dcf2611ac24829ffe80cf46894ebc98fdda62e0c
1825
:git: https://github.com/kylef/Stencil
1926

2027
SPEC CHECKSUMS:
28+
Commander: d67100926f8781c33b4cb82aa5d826bad78b4191
2129
PathKit: dd424f40892d4f60f279c8f2cd82503fc86e4dad
2230
Stencil: 4214b68cf5a5f24c74c8c6fbbb573e225c490f88
2331

24-
COCOAPODS: 0.39.0.beta.4
32+
COCOAPODS: 0.38.2

bin/querykit.swift

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env xcrun swift -F Rome
22

33
import CoreData
4+
import Commander
45
import PathKit
56
import Stencil
67

@@ -201,26 +202,20 @@ func generate(modelPath:Path, outputPath:Path) {
201202
}
202203
}
203204

204-
func usage() {
205-
let processName = Process.arguments.first!
206-
print("Usage: \(processName) <model> <output-directory>")
207-
}
208-
209-
func run() {
210-
let arguments = Process.arguments
211-
212-
if arguments.contains("--help") {
213-
usage()
214-
} else if arguments.contains("--version") {
215-
print(version)
216-
} else if arguments.count != 3 {
217-
usage()
218-
} else {
219-
let modelPath = Path(arguments[1])
220-
let outputPath = Path(arguments[2])
221-
generate(modelPath, outputPath: outputPath)
205+
extension Path: ArgumentConvertible {
206+
public init(parser: ArgumentParser) throws {
207+
if let path = parser.shift() {
208+
self.init(path)
209+
} else {
210+
throw ArgumentError.MissingValue(argument: nil)
211+
}
222212
}
223213
}
224214

225-
run()
215+
command(
216+
Argument<Path>("model"),
217+
Argument<Path>("output")
218+
) { model, output in
219+
generate(model, outputPath: output)
220+
}.run(version)
226221

0 commit comments

Comments
 (0)