diff --git a/README.md b/README.md index 2e033c1..a46d1ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Terminal in React -![version](https://img.shields.io/badge/terminal--in--react-2.2.1-brightgreen.svg) -![size](https://img.shields.io/badge/size-35.5%20KB-brightgreen.svg) +![version](https://img.shields.io/badge/terminal--in--react-3.0.0-brightgreen.svg) +![size](https://img.shields.io/badge/size-33.4%20KB-brightgreen.svg) +![size](https://img.shields.io/badge/gzip-9.85%20KB-brightgreen.svg)

@@ -42,7 +43,7 @@ class App extends Component { showmsg: this.showMsg, popup: () => alert("Terminal in React") }} - description={{ + descriptions={{ 'open-google': 'opens google.com', showmsg: 'shows a message', alert: 'alert', popup: 'alert' @@ -63,6 +64,8 @@ class App extends Component { ## Working +### Adding commands + To add your own command, use prop `commands` which accepts an object. This objects then maps `command name -> command function`. Let's take an example. You want to open a website with a command `open-google` @@ -71,13 +74,17 @@ Let's take an example. You want to open a website with a command `open-google` window.open("https://www.google.com/", "_blank")}} /> ``` +### Adding description of your command + Add a description of your command using prop `description`. ```jsx - + ``` -You can have the terminal watch console.log/info function and print out. Thank you so much [Jonathan Gertig](https://github.com/jcgertig) for this 👇 +### Console logging + +You can have the terminal watch console.log/info function and print out. ```jsx @@ -87,11 +94,15 @@ You can have the terminal watch console.log/info function and print out. Thank y

+### Command passthrough You can have the terminal pass out the cmd that was input + ```jsx `-PassedThrough:${cmd}: command not found`} /> ``` + +### Async handling of commands you can also handle the result with a callback ```jsx ``` -Minimise, maximise and close the window +### Minimise, maximise and close the window

-## Advanced commands +### Hide the default options + +```jsx + +``` + +This will hide the option color, show and clear. + + +### Advanced commands + You can give your commands options and get them back parsed to the method. Using this method will also give your command a build in help output. With the option `-h` or `--help`. @@ -131,10 +152,7 @@ With the option `-h` or `--help`. }} /> ``` -

- -

- + The command Api has three parameters `arguments`, `print`, and `runCommand`. @@ -145,8 +163,68 @@ The command Api has three parameters `arguments`, `print`, and `runCommand`. as a result of a command will also be printed. - `runCommand` is a method to call other commands it takes a string and will attempt to run the command given - - Check [this](./starter/App.js) example for more information. + +Let's take an another example - + +```jsx + { + const text = args.slice(1).join(' '); + print(''); + for (let i = 0; i < text.length; i += 1) { + setTimeout(() => { + runCommand(`edit-line ${text.slice(0, i + 1)}`); + }, 100 * i); + } + } + }} +/> + +``` + + + +### Using plugins 🔥 + +We have also developed a plugin system for the `` component which helps you develop custom plugins. Here is one example of plugin which creates a fake file system called [terminal-in-react-pseudo-file-system-plugin](https://github.com/jcgertig/terminal-in-react-pseudo-file-system-plugin). + +#### Instantiating the plugin + +```jsx +import PseudoFileSystem from 'terminal-in-react-pseudo-file-system-plugin' + + +``` +

+ +

+ +Awesome! Right? Let us know if you make something interesting 😃 + +### Tab autocomplete + +

+ +

+ +### Multiline input + +via `shift + enter` + +

+ +

+ +### Check history of your commands + +

+ +

## Customization @@ -157,13 +235,6 @@ Use * prop `barColor` to change the color of bar. * prop `prompt` to change the prompt (`>`) color. -## What's more ? - -* will support images, gifs -* plugins -* tab autocomplete -* multiline input - Follow me on Twitter [@NTulswani](https://twitter.com/NTulswani) for new updates and progress 😄 ## API @@ -179,7 +250,8 @@ Follow me on Twitter [@NTulswani](https://twitter.com/NTulswani) for new updates | **msg** | string | - | | **watchConsoleLogging** | bool | false | | **commandPassThrough** | function | null | - +| **promptSymbol** | string | > | +| **plugins** | array | [ { name: '', load: new Plugin(), commands: {} descriptions: {} } ] | ## Built-in commands @@ -189,10 +261,6 @@ Follow me on Twitter [@NTulswani](https://twitter.com/NTulswani) for new updates * `echo` - Outputs anything given * `edit-line` - Edits the last line or a given line using the `-l` argument -## Built-in functionality - -Check the history of your commands by pressing key up and key down. - ## Where to use ? * Embed it as a toy on your website