mirror of
https://github.com/github/semantic.git
synced 2024-11-24 17:04:47 +03:00
We’ll always have a pair of sources.
This commit is contained in:
parent
b9f739844f
commit
202bc2b31b
@ -1,26 +1,23 @@
|
||||
/// A list of arguments for the difftool.
|
||||
enum Argument {
|
||||
indirect case Sources(Source, Source, Argument)
|
||||
indirect case OutputFlag(Output, Argument)
|
||||
case End
|
||||
case Sources(Source, Source)
|
||||
|
||||
private var rest: Argument? {
|
||||
switch self {
|
||||
case let .Sources(_, _, rest):
|
||||
return rest
|
||||
case let .OutputFlag(_, rest):
|
||||
return rest
|
||||
case .End:
|
||||
case .Sources:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var sources: (Source, Source)? {
|
||||
var sources: (Source, Source) {
|
||||
switch self {
|
||||
case let .Sources(a, b, _):
|
||||
case let .Sources(a, b):
|
||||
return (a, b)
|
||||
default:
|
||||
return rest?.sources
|
||||
case let .OutputFlag(_, rest):
|
||||
return rest.sources
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +49,7 @@ private let source: Madness.Parser<[String], Source>.Function =
|
||||
|
||||
let argumentsParser: Madness.Parser<[String], Argument>.Function = any // skip the path to the difftool
|
||||
*> (curry(Argument.OutputFlag) <^> flag)
|
||||
<*> (curry(Argument.Sources) <^> source <*> source <*> pure(Argument.End))
|
||||
<*> (curry(Argument.Sources) <^> source <*> source)
|
||||
|
||||
import Madness
|
||||
import Prelude
|
||||
|
@ -145,7 +145,7 @@ func parserForType(type: String) -> String throws -> Term {
|
||||
|
||||
let parsed = parse(argumentsParser, input: Process.arguments)
|
||||
let arguments: Argument = try parsed.either(ifLeft: { throw "\($0)" }, ifRight: { $0 })
|
||||
guard let (aSource, bSource) = arguments.sources else { throw "expected two sources" }
|
||||
let (aSource, bSource) = arguments.sources
|
||||
let jsonURL = NSURL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true).URLByAppendingPathComponent("diff.json")
|
||||
guard let uiPath = NSBundle.mainBundle().infoDictionary?["PathToUISource"] as? String else { throw "need ui path" }
|
||||
guard aSource.type == bSource.type else { throw "can’t compare files of different types" }
|
||||
|
Loading…
Reference in New Issue
Block a user