terminal-in-react icon indicating copy to clipboard operation
terminal-in-react copied to clipboard

Disable Built in commands

Open jseparovic opened this issue 2 years ago • 3 comments

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 avatar Jun 15 '22 03:06 jseparovic

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 avatar Jun 15 '22 04:06 jseparovic

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

jseparovic avatar Jun 15 '22 07:06 jseparovic

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");
          });
        },
      }}

sahinme avatar Apr 01 '24 13:04 sahinme