Describe the problem
Using the code provided in the current README documentation for a custom printer results in errors.
Steps to reproduce the problem
Following the README’s custom printer example, such as creating a Ruby project that uses tty-command and pasting the code exactly as shown, will cause an error.
Code example provided in the README
CustomPrinter < TTY::Command::Printers::Abstract
def write(cmd, message)
puts cmd.to_command + message
end
end
cmd = TTY::Command.new(printer: CustomPrinter)
# .../tty-command/README.md:609-617
Actual behaviour
Issues:
- The first error occurs because the provided snippet is not valid Ruby syntax. It is missing the
class keyword before CustomPrinter.
- After fixing that, invoking
cmd produces an error (wrong number of arguments (given 1, expected 2)) because methods like print_command_start, which are defined in the abstract printer, call write with a single argument, causing a mismatch with the expected method signature.
Expected behaviour
The code in the documentation should work as provided, without raising any errors. It would also be helpful for the Abstract printer class to more closely match the structure and method signatures of the other printer classes.
Describe the problem
Using the code provided in the current README documentation for a custom printer results in errors.
Steps to reproduce the problem
Following the README’s custom printer example, such as creating a Ruby project that uses tty-command and pasting the code exactly as shown, will cause an error.
Code example provided in the README
Actual behaviour
Issues:
classkeyword beforeCustomPrinter.cmdproduces an error (wrong number of arguments (given 1, expected 2)) because methods likeprint_command_start, which are defined in the abstract printer, callwritewith a single argument, causing a mismatch with the expected method signature.Expected behaviour
The code in the documentation should work as provided, without raising any errors. It would also be helpful for the Abstract printer class to more closely match the structure and method signatures of the other printer classes.