Giter Club home page Giter Club logo

Comments (5)

benmneb avatar benmneb commented on June 2, 2024

#38 should fix this.

But it would also be nice to allow a function prop to include the errored command in the error message, to replicate real CLI's better, something like:
errorMessage={(err) => <span style={{color: 'red'}}>Command not found: {err}</span> would be perfect.

Currently this only returns something if the errored command has a whitespace in it, and it returns everything after the first whitespace, like its being split there or something... ie

>>> first second third etc
Unknown command: second third etc

from react-terminal.

benmneb avatar benmneb commented on June 2, 2024

In the meantime I've been using something like this, which actually works fine.

const themes = {
  ocean: {
    themeBGColor: "#224fbc",
    themeToolbarColor: "#216dff",
    themeColor: "#e5e5e5",
    themePromptColor: "#00e5e5",
    errorColor: "#e5e500",
    linkColor: "#e5e5e5"
  }
  // etc etc
};

const error = {
  color: themes[theme].errorColor,
  fontWeight: "bold"
};
const success = {
  color: themes[theme].successColor,
  fontWeight: "bold"
};

const commands = {
  send: (input) => {
    if (!input) {
      return <span style={error}>Nothing to send</span>;
    }
       
     return <span style={success}>Sent succesfully</span> 
}

<ReactTerminal
    commands={commands}
    errorMessage={<span style={error}>Command not found</span>}
    themes={themes}
    theme={theme}
  />

from react-terminal.

bony2023 avatar bony2023 commented on June 2, 2024

This looks like a great feature. I think we can modify the caller function to include extra terminal-related arguments which can include a bunch of data including the command.

from react-terminal.

bony2023 avatar bony2023 commented on June 2, 2024

Support on a theme level could be useful. I would imagine something would need to be edited around here in addition to the theme objects, but I'm not really sure how to go about it myself.

You are absolutely correct. More specifically here, we need to pass the command as well along with commandArguments

from react-terminal.

bony2023 avatar bony2023 commented on June 2, 2024

This can be a quick fix, but more future proof approach would be to go with the extra data passed on to the callback function.

from react-terminal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.