nitin42 / terminal-in-react

👨‍💻 A component that renders a terminal
http://terminal-in-react.surge.sh/
MIT License
2.12k stars 151 forks source link

Disable Built in commands #107

Open jseparovic opened 2 years ago

jseparovic commented 2 years ago

Any chance of adding the ability to disable builtin commands? I'd like to use this component as a passthrough to a cisco router, but I can't run any show commands because it's a built-in command.

jseparovic commented 2 years ago

I created this PR, although I couldn't figure out how to stop the "show" command being called on load. But this PR allows me to run passthrough "show" commands now. Cheers https://github.com/nitin42/terminal-in-react/pull/108

jseparovic commented 2 years ago

I tried using plugin take control, but then I lost history and ability to change the prompt. Being able to disable the builtin commands and using plugins for output and prompt control worked for my use case. Cheers. Thanks heaps for this library. Really cool

sahinme commented 3 months ago

You don't need extra plugin or anything, just override commands props for built-in commands

commands={{
        show: (args, print, runCommand, ...rest) => {
          print("waiting for response...");
          sendCommand("show", Mac).then((res) => {
            !!res ? print(<pre>{res}</pre>) : print("No response");
          });
        },
        help: (args, print, runCommand, ...rest) => {
          print("waiting for response...");
          sendCommand("help", Mac).then((res) => {
            !!res ? print(<pre>{res}</pre>) : print("No response");
          });
        },
      }}