Functionality to streamline the process of scripting for the console with javascript
npm install @byte-this/js-clitypescript
const TestCommand: iCliCommand = {
name: "Test Command", //name for internal use
displayText: "Print some test text to the console",
tokens: ["test-print", "t-p"],
requiredParams: [
{
name: "txt",
displayText: "Text to print",
},
],
execute: async (
params: { txt: string },
cliOutputter: iCliOutputter
): Promise => {
cliOutputter.pushMessage("Txt from user ==>", params.txt);
},
};
`
With this kind of definition, the program will request everything under requiredParams from the user, then execute the command and pass in those required commands.
Then, we setup our application runner:
`typescript
const app = new CliApplication();
app.onQuit(() => {
process.exit(0);
});
app.startApp(
{
startup: {
initialOutput: "Welcome to the example application",
},
},
new ArrayCliCommandsCollection(commands),
[...process.argv].slice(2),
new ConsoleOutputter(),
new ConsoleUserInputRequestor(new ConsoleOutputter())
);
``