noahra / byteblitz

A CLI-tool for viewing the binary content of files.
GNU General Public License v3.0
24 stars 0 forks source link

Add support for output redirection to file. #15

Open noahra opened 8 months ago

noahra commented 8 months ago

Issue Description:

Feature Request: Output Redirection to file

Background:

Currently, byteblitz allows users to view the binary content of files. However, it cannot directly redirect the output to a file using the standard output redirection operator (>).

Proposed Feature: Implement functionality in byteblitz so that users can redirect the formatted output directly to a target file using the > operator. The expected command structure after implementation would be:

byteblitz -<format> <filename> > output.file 

Example: If a user wants to view the contents of a file named cool.png in hexadecimal , and save the formatted result into output.txt, they could use:

byteblitz -hex document.txt > output.txt
arthurbacci commented 7 months ago

POSIX has isatty(). Some of the libraries used probably implement this feature.

arthurbacci commented 7 months ago

Actually it's part of Rust's std :). https://doc.rust-lang.org/std/io/trait.IsTerminal.html

arthurbacci commented 7 months ago

A question before implementing it:

arthurbacci commented 7 months ago

SUSv1's System Interface Definitions, Issue 4, Version 2 describes the behaviour of /dev/tty for getting access to the terminal to ignore redirections (pipes). This should be portable to nearly all unix-like systems.

noahra commented 7 months ago

@arthurbacci The Issue is now updated. I was unclear with my intentions, I hope it is clearer now.

arthurbacci commented 7 months ago

ok, I will open a separate issue for the output