Created
March 29, 2014 19:34
-
-
Save shajra/9861419 to your computer and use it in GitHub Desktop.
could this be cleaner?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setFromArgs(args: Args): Settings => Settings = { | |
val input = | |
args optional "input" map { i => | |
{ s: Settings => s copy (inputBasePath=InputBasePath(i)) } endo | |
} orZero | |
val dataCenters = | |
(args list "data-centers" some) filterNot { _.isEmpty } map { dcs => | |
{ s: Settings => s copy (dataCenters = dcs map DataCenter.apply) } endo | |
} orZero | |
val lastDays = | |
args optional "last-days" map { s => | |
s.parseInt fold | |
(sys error "couldn't parse --last-days $s as integer", LastDays) | |
} map { lds => { s: Settings => s copy (lastDays=lds) } endo } orZero | |
val eventTypes = | |
(args list "event-types" some) filterNot { _.isEmpty } map { ets => | |
{ s: Settings => s copy (eventTypes = ets map EventType.apply) } endo | |
} orZero | |
val output = | |
args optional "output" map { o => | |
{ s: Settings => s copy (outputFilename=OutputFilename(o)) } endo | |
} orZero | |
input |+| dataCenters |+| lastDays |+| eventTypes |+| output run | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment