tut icon indicating copy to clipboard operation
tut copied to clipboard

Max Line Length option

Open Jacoby6000 opened this issue 8 years ago • 4 comments

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...

Jacoby6000 avatar May 22 '16 22:05 Jacoby6000

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.

ruippeixotog avatar May 01 '17 23:05 ruippeixotog

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.

tpolecat avatar May 02 '17 00:05 tpolecat

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?

ruippeixotog avatar May 02 '17 20:05 ruippeixotog

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.

tpolecat avatar May 02 '17 21:05 tpolecat