-
-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Labels
Description
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-617Actual behaviour
Issues:
- The first error occurs because the provided snippet is not valid Ruby syntax. It is missing the
classkeyword beforeCustomPrinter. - After fixing that, invoking
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.