diff --git a/README.md b/README.md
index 3b5df41..5bb3874 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,6 @@
Simple and interactive solution to provide a list of selectable items on the command line.
-
> Note: cli-select does not produce colored output by default to keep the dependencies at a minimum. See the [examples](#examples) below on how to reproduce this preview.
@@ -29,8 +28,7 @@ npm install --save cli-select
## Usage
```javascript
-const cliSelect = require('cli-select');
-
+import cliSelect from 'cli-select';
cliSelect(options, callback);
```
@@ -161,23 +159,25 @@ These two packages are also used in the examples below but `cli-select` is also
### Custom value renderer
+
+
```javascript
-const cliSelect = require('cli-select');
-const chalk = require('chalk');
+import cliSelect from 'cli-select';
+import chalk from 'chalk';
cliSelect({
- values: ['Major', 'Minor', 'Patch'],
- valueRenderer: (value, selected) => {
- if (selected) {
- return chalk.underline(value);
- }
-
- return value;
- },
-}).then(...);
-```
+ values: ['Major', 'Minor', 'Patch'],
+ valueRenderer: (value, selected) => {
+ if (selected) {
+ return chalk.underline(value);
+ }
-Todo: more examples, also the one in the preview gif
+ return value;
+ },
+}).then((option) => {
+ console.log(`Option selected: ${option.value}`)
+});
+```
## License
diff --git a/example.gif b/example.gif
new file mode 100644
index 0000000..a97a635
Binary files /dev/null and b/example.gif differ
diff --git a/examples/basic/index.js b/examples/basic/index.js
new file mode 100644
index 0000000..e127a1e
--- /dev/null
+++ b/examples/basic/index.js
@@ -0,0 +1,15 @@
+import cliSelect from 'cli-select';
+import chalk from 'chalk';
+
+cliSelect({
+ values: ['Major', 'Minor', 'Patch'],
+ valueRenderer: (value, selected) => {
+ if (selected) {
+ return chalk.underline(value);
+ }
+
+ return value;
+ },
+}).then((option) => {
+ console.log(`Option selected: ${option.value}`)
+});
\ No newline at end of file
diff --git a/examples/basic/package.json b/examples/basic/package.json
new file mode 100644
index 0000000..fc72a19
--- /dev/null
+++ b/examples/basic/package.json
@@ -0,0 +1,17 @@
+{
+ "name": "basic",
+ "type": "module",
+ "version": "1.0.0",
+ "description": "A basic example",
+ "main": "index.js",
+ "scripts": {
+ "start": "node index.js"
+ },
+ "keywords": [],
+ "author": "",
+ "license": "MIT",
+ "dependencies": {
+ "chalk": "^5.3.0",
+ "cli-select": "^1.1.2"
+ }
+}