Skip to content

Commit 10c1a12

Browse files
committed
remove isatty andstream information
1 parent e3981b4 commit 10c1a12

File tree

5 files changed

+21
-50
lines changed

5 files changed

+21
-50
lines changed

argparse/src-3/argparse/core/Command.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,7 @@ object CommandMacros:
279279
val pr = ${printer.asExpr}.asInstanceOf[p.Printer[Any]]
280280
pr.print(
281281
callOrInstantiate(),
282-
System.out,
283-
OutputApi.StreamInfo(
284-
isatty = Platform.isConsole()
285-
)
282+
System.out
286283
)
287284
}
288285
parser

argparse/src-3/argparse/core/OutputApi.scala

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,11 @@ trait OutputApi extends ParsersApi with TypesApi with Printers:
2323
trait Printer[A]:
2424
def print(
2525
a: A,
26-
out: java.io.PrintStream,
27-
info: OutputApi.StreamInfo
26+
out: java.io.PrintStream
2827
): Unit
2928

3029
object OutputApi:
3130

32-
case class StreamInfo(
33-
isatty: Boolean
34-
)
35-
3631
enum Alignment:
3732
case Left
3833
case Right
@@ -216,44 +211,40 @@ trait Printers extends LowPrioPrinters:
216211
self: OutputApi =>
217212

218213
given Printer[Unit] with
219-
def print(a: Unit, out: java.io.PrintStream, info: OutputApi.StreamInfo): Unit = ()
214+
def print(a: Unit, out: java.io.PrintStream): Unit = ()
220215

221216
given Printer[Array[Byte]] with
222-
def print(a: Array[Byte], out: java.io.PrintStream, info: OutputApi.StreamInfo): Unit =
217+
def print(a: Array[Byte], out: java.io.PrintStream): Unit =
223218
out.write(a)
224219

225220
given Printer[geny.Writable] with
226-
def print(a: geny.Writable, out: java.io.PrintStream, info: OutputApi.StreamInfo): Unit =
221+
def print(a: geny.Writable, out: java.io.PrintStream): Unit =
227222
a.writeBytesTo(out)
228223

229224
given [A](using p: Printer[A]): Printer[geny.Generator[A]] with
230-
def print(value: geny.Generator[A], out: java.io.PrintStream, info: OutputApi.StreamInfo): Unit =
231-
value.foreach(v => p.print(v, out, info))
225+
def print(value: geny.Generator[A], out: java.io.PrintStream): Unit =
226+
value.foreach(v => p.print(v, out))
232227

233228
inline given productListPrinter[A <: Iterable[B], B <: Product](using m: ProductLabels[B]): Printer[A] with
234-
def print(value: A, out: java.io.PrintStream, info: OutputApi.StreamInfo): Unit =
229+
def print(value: A, out: java.io.PrintStream): Unit =
235230
val rows = value.map(_.productIterator.toIterable)
236-
if info.isatty then
237-
out.println(OutputApi.tabulate(rows, header = m.labels.map(_.toUpperCase)))
238-
else
239-
out.println(OutputApi.tabulate(rows, header = Iterable.empty))
231+
out.println(OutputApi.tabulate(rows, header = m.labels.map(_.toUpperCase)))
240232

241233
given nonProductListPrinter[A <: Iterable[B], B](using elemPrinter: Printer[B]): Printer[A] with
242-
def print(value: A, out: java.io.PrintStream, info: OutputApi.StreamInfo): Unit =
243-
for elem <- value do elemPrinter.print(elem, out, info)
234+
def print(value: A, out: java.io.PrintStream): Unit =
235+
for elem <- value do elemPrinter.print(elem, out)
244236

245237
given [A](using p: Printer[A]): Printer[concurrent.Future[A]] with
246-
def print(value: concurrent.Future[A], out: java.io.PrintStream, info: OutputApi.StreamInfo): Unit =
238+
def print(value: concurrent.Future[A], out: java.io.PrintStream): Unit =
247239
p.print(
248240
concurrent.Await.result(value, concurrent.duration.Duration.Inf),
249-
out,
250-
info
241+
out
251242
)
252243

253244
trait LowPrioPrinters:
254245
self: OutputApi =>
255246

256247
// fallback to always print something
257248
given [A]: Printer[A] with
258-
def print(a: A, out: java.io.PrintStream, info: OutputApi.StreamInfo): Unit =
249+
def print(a: A, out: java.io.PrintStream): Unit =
259250
out.println(a.toString)

argparse/src-jvm/argparse/core/Platform.scala

Lines changed: 0 additions & 5 deletions
This file was deleted.

argparse/src-native/argparse/core/Platform.scala

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
$ app
2-
item1 2.0
2+
NAME VALUE COMMENT
3+
item1 2.0
34
item2 0.213 notice the numeric alignment
4-
item3 -100.2
5-
item4 10.2 a comment
6-
another_item 12.54 a comment
7-
12.54 item has no name
8-
etc 0.0 ...
5+
item3 -100.2
6+
item4 10.2 a comment
7+
another_item 12.54 a comment
8+
12.54 item has no name
9+
etc 0.0 ...

0 commit comments

Comments
 (0)