tut
tut copied to clipboard
Max Line Length option
I currently have a section where I don't want to supress output, but one of the output lines is ridiculously long. I'd like to be able to have lines truncate once they reach a certain length.
Relevant output:
q: scoobie.dsl.weak.sql.QueryBuilder[shapeless.HNil,shapeless.::[scoobie.ast.QueryProjection[shapeless.::[Int,shapeless.HNil]],shapeless.::[scoobie.ast.QueryProjection[shapeless.HNil],shapeless.HNil]],shapeless.::[scoobie.ast.QueryUnion[shapeless.HNil],shapeless.::[scoobie.ast.QueryUnion[shapeless.HNil],shapeless.HNil]],shapeless.::[Int,shapeless.HNil],shapeless.HNil,this.Out,shapeless.::[Int,shapeless.HNil],shapeless.::[Int,shapeless.HNil],this.Out] = QueryBuilder(QueryProjectOne(QueryPathEnd(bar),None),QueryProjectOne(QueryAdd(QueryPathEnd(foo),QueryParameter(10 :: HNil),10 :: HNil),Some(woozle)) :: QueryProjectAll :: HNil,QueryLeftOuterJoin(QueryProjectOne(QueryPathEnd(baz),Some(b)),QueryEqual(QueryPathCons(bar,QueryPathEnd(id)),QueryPathCons(b,QueryPathEnd(barId)),HNil),HNil) :: Que...
I would also like to have that feature available as a modifier like :truncate
. Many times, particularly when defining intermediate vals
, the string representation is way too big and not relevant, while the final results usually have short representations.
@tpolecat, if you agree with the feature, I can give a try at a PR for adding that.
You're welcome to give this a try but the IO situation is quite complicated. You will need to add a
char-counting/line-chopping mode to Spigot
that you turn on and off in Tut
, similar to the way setActive
is handled.
People have also asked for line-wrapping, which isn't any harder than truncation (don't worry about finding word boundaries for now) so you might do that as well.
Ok, I understand. I'll try it and if I'm able to do it I'll submit a PR :)
One question: from a quick look at the core classes, it seems Tut
works always with OutputStream
instances, like Spigot
. Wouldn't it make more sense if it worked with Writers wrapping the REPL output stream, since it's always a character stream? Or do you work on OutputStream
directly for performance reasons?
It's possible that it could be simplified, but keep in mind that output from tut, from the REPL, and from stdout all gets funneled to the same underlying output stream. We're also stripping out ANSI escapes. So it's kind of complicated.