Comments (5)
#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.
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.
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.
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.
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)
- warning Uncaught TypeError: Cannot read properties of null (reading 'bufferedContent') HOT 4
- Run commands upon button press HOT 1
- Additional user inputs after command HOT 3
- Firefox copy paste TypeError: navigator.clipboard.readText is not a function HOT 3
- It would be nice to have mobile functionality HOT 3
- TypeError: Cannot read properties of null (reading 'bufferedContent') HOT 3
- Duplicate responses on two terminals HOT 1
- Adding a option to push messages from outside the terminal HOT 3
- Output of the defaultHandler not preserving new line characters. HOT 1
- Keyboard not being invoked in android HOT 2
- bug(mobile): jumps to top of page onfocus
- Support for JS/TS default parameters
- Run `clear` on eventHandler HOT 1
- Support for multiline input
- Bug in mobiile view: Scrolls to top of application when clicked (touch in mobile).
- Example of programmatically running commands
- Empty spaces are getting automatically removed HOT 2
- Terminal Cursor
- autocomplete and custom styles HOT 4
- Feature request: width of terminal in number of characters
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-terminal.