Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI.pipe not working with Enumerator.generateM #6

Closed
gre opened this issue Dec 31, 2012 · 1 comment
Closed

CLI.pipe not working with Enumerator.generateM #6

gre opened this issue Dec 31, 2012 · 1 comment
Labels

Comments

@gre
Copy link
Owner

gre commented Dec 31, 2012

  import collection.immutable.StringOps
  import play.api.libs.concurrent.Promise.timeout
  import concurrent.{Await}
  import concurrent.duration.Duration
  val maxDuration = Duration.Inf
  val stringToBytes = (str: StringOps) => str.map(_.toByte).toArray
  val bytesJoinConsumer = Iteratee.fold[Array[Byte], Array[Byte]](Array[Byte]())((a, b) => a++b)
  val nbOfLines = 3
  val line = stringToBytes("hello\n")
  val enum = Enumerator.generateM[Array[Byte]] {
    timeout(Some(line), 5)
  }
  val pipe = CLI.pipe(Seq("head", "-n", nbOfLines.toString), 10)

  val result: Array[Byte] = Await.result(enum &> pipe |>>> bytesJoinConsumer, maxDuration)
  println(result.map(_.toChar).mkString)
@gre
Copy link
Owner Author

gre commented Jan 8, 2013

Fixed with commit c723bb8

@gre gre closed this as completed Jan 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant