This command illustrates an interactive List, as well as using Tab to navigate to another location within the command.
In this case, hitting Enter on an Option will copy the special character, while hitting Tab will show another view letting someone choose to copy the hex value instead.
/* * A command that shows special characters. Hitting Enter * will copy character, hitting Tab will give other ways * to copy the character: HTML hex code, for example. *//** * Gets arguments passed in to script, like: --character=control * and stores it into an array, like: args['character'] = "control". */constargs=process.argv.slice(2).reduce((agg, arg) => {constmatch=arg.match(/^--(?<key>\w+)=(?<value>.+)$/);return match ? { ...agg, [match.groups.key]:match.groups.value } : agg;}, {});let response;if (args["character"]) { response =showOptionsForCharacter(args["character"]);} else { response =showAllCharacters();}console.log(JSON.stringify(response));/* * The view that is shown when someone runs the command. */functionshowAllCharacters() {constresponse= { view: { type:"list", options: [ { title:"Command", action: { type:"copy", value:"⌘", }, moveAction: { type:"add-param", name:"character", value:"command", }, }, { title:"Option", action: { type:"copy", value:"⌥", }, moveAction: { type:"add-param", name:"character", value:"option", }, }, { title:"Control", action: { type:"copy", value:"️️⌃", }, moveAction: { type:"add-param", name:"character", value:"control", }, }, ], }, };return response;}/** * The view that is shown when someone Tabs on a character. */functionshowOptionsForCharacter(character) {constcharactersToHex= { command:"⌘", option:"⌥", control:"⌃", };return { tokens: [ { paramName:"character", label: character, icon:"🎹", }, ], view: { type:"list", options: [ { title:"Copy Hex", action: { type:"copy", value: charactersToHex[character], }, }, ], }, };}