Skip to content

Issue #83 : warn before printing binary (or non-printable) content

David J Peacock requested to merge aki237:binary-out into master

Created by: aki237

Detailed : A new interface which has some basic *os.File methods called OutFile is added. This has all the basic *os.File functions needed by kurly like Seek, Read, Write, Close, Stat etc., So we can add new type following this interface, which can be used for various types of outputs. Basically this works for a simple *os.File.

To fix the issue a new type is added, called Safestdout, wrapping a *os.File (embedded) with an overridden Write method. Here the write method checks for binary content in the byte array passed for the first time. Then is written in underlying file (os.Stdout). This wrapped mechanism can be used to manipulate how the data shown in the terminal. Like for example, an option can be added to add a syntax highlighting for the incoming content.

Merge request reports