@hangtime/grip-connect-cli
Version:
CLI tool for Grip Connect devices
96 lines • 3.11 kB
JavaScript
/**
* Device definition for the Griptonite Motherboard.
*/
import select from "@inquirer/select";
import pc from "picocolors";
import { Motherboard } from "@hangtime/grip-connect-runtime";
import { printResult, printSuccess } from "../utils.js";
const motherboard = {
name: "Motherboard",
class: Motherboard,
actions: [
{
name: "Battery",
description: "Read battery level",
run: async (device) => {
const d = device;
printResult("Battery:", await d.battery());
},
},
{
name: "Calibration",
description: "Request calibration data",
run: async (device) => {
const d = device;
await d.calibration();
printSuccess("Calibration data requested.");
},
},
{
name: "Firmware",
description: "Read firmware version",
run: async (device) => {
const d = device;
printResult("Firmware:", await d.firmware());
},
},
{
name: "Hardware",
description: "Read hardware version",
run: async (device) => {
const d = device;
printResult("Hardware:", await d.hardware());
},
},
{
name: "LED",
description: "Set LED color (green / red / orange / off)",
run: async (device) => {
const d = device;
const color = await select({
message: "LED color:",
choices: [
{ name: "Green", value: "green" },
{ name: "Red", value: "red" },
{ name: "Orange", value: "orange" },
{ name: "Off", value: "off" },
],
});
await d.led(color === "off" ? undefined : color);
printSuccess(`LED set to ${color}.`);
},
},
{
name: "Manufacturer",
description: "Read manufacturer info",
run: async (device) => {
const d = device;
printResult("Manufacturer:", await d.manufacturer());
},
},
{
name: "Serial",
description: "Read serial number",
run: async (device) => {
const d = device;
printResult("Serial:", await d.serial());
},
},
{
name: "Text",
description: "Read device text memory",
run: async (device) => {
const d = device;
const text = await d.text();
if (text) {
console.log(pc.cyan(`\nText memory:\n${text}`));
}
else {
console.log(pc.dim("\nNo text data."));
}
},
},
],
};
export default motherboard;
//# sourceMappingURL=motherboard.js.map