Skip to content

Instantly share code, notes, and snippets.

@Mortimerp9
Created May 6, 2014 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mortimerp9/78d8194bc2c808908ddc to your computer and use it in GitHub Desktop.
Save Mortimerp9/78d8194bc2c808908ddc to your computer and use it in GitHub Desktop.
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