Features • Installation • Usage • Props • Report a bug
TODO
Install package with NPM or YARN and add it to your development dependencies:
npm install prompt-ui
OR
yarn add prompt-ui
import { PromptShell } from "prompt-ui";
function App(props) {
// Define commands here
const commands = {
TODO
};
return (
<PromptShell
commands={commands}
/>
);
}
Also make sure to wrap the main mount point around the PromptContextProvider. This retains the state even when the component is unmounted and then mounted back:
import { PromptContextProvider } from "prompt-ui";
ReactDOM.render(
<PromptContextProvider>
<App/>
</PromptContextProvider>,
rootElement
);
Create an HTML page, or edit an existing one, and add the following within the body tags:
<prompt TODO></prompt>
<script src="https://unpkg.com/prompt-ui> </script>
Open the HTML file in your browser, and your prompt interface will be displayed on page.
The component comes with few in-built themes: light, dark. You can also create custom themes by passing themes parameter in props, as follows:
<PromptShell
commands={commands}
settings={settings}
/>
| name | description | default |
|---|---|---|
commands |
List of commands to be provided as a key value pair where value can be either a string, JSX/HTML tag or callback | null |
errorMessage |
Message to show when unidentified command executed, can be either a string, JSX/HTML tag or callback | "not found!" |
settings |
Prompt settings defining the appearance and behavior of the Prompt. This includes properties such as the prompt displayed at the beginning of input and the theme applied to the PromptShell interface. See Default Settings for default values and configurations. | null |
interface Settings {
prompt: "$";
theme: Theme;
// TODO
}interface Theme {
// TODO
}| command | description |
|---|---|
| clear | clears the console |
| history | show last {property.historySize} inputs |
If you found a bug in this library, please file an GitHub issue here.