Created
May 6, 2014 13:39
-
-
Save Mortimerp9/78d8194bc2c808908ddc to your computer and use it in GitHub Desktop.
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
import com.quantifind.sumac.{FieldArgs, ArgMain} | |
class RangeArgs extends FieldArgs { | |
var from: Int = 0 | |
var to: Option[Int] = None | |
@FileExists | |
var file: File = _ | |
} | |
class FileRange extends ArgMain[RangeArgs] { | |
def main(args: RangeArgs) { | |
val lines = scala.io.Source.fromFile(args.file).getLines | |
.drop(args.from) | |
args.to.map(to => lines.take(to)).getOrElse(lines) | |
.foreach(println) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment