mirror of
https://github.com/charmbracelet/gum.git
synced 2024-09-11 06:16:03 +03:00
docs: Add node.js embedding gum example
This commit is contained in:
parent
671777aa59
commit
98353ae4d3
13
examples/gum.js
Normal file
13
examples/gum.js
Normal file
@ -0,0 +1,13 @@
|
||||
const { spawn } = require("child_process");
|
||||
|
||||
const activities = ["walking", "running", "cycling", "driving", "transport"];
|
||||
|
||||
console.log("What's your favorite activity?")
|
||||
const gum = spawn("gum", ["choose", ...activities]);
|
||||
|
||||
gum.stderr.pipe(process.stderr);
|
||||
|
||||
gum.stdout.on("data", data => {
|
||||
const activity = data.toString().trim();
|
||||
console.log(`I like ${activity} too!`);
|
||||
});
|
Loading…
Reference in New Issue
Block a user