Skip to content

I need Help #29

Answered by m4tt72
adamthewarrior asked this question in Q&A
Jul 11, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hello @loeffea886,

Let's create a helloWorld command, it will take no parameters, and will return a string in the terminal displaying Hello World.

First, you need to create a file in src/utils/bin called helloWorld.ts.

Then export a function helloWorld like the following:

export const helloWorld = async (args: string[]): Promise<string> => {
  return 'Hello world';
};

Now we need to export all the functions from that file in src/utils/bin/index.ts:

// ... The previous exports
export * from './helloWorld';

Done ;)

Passing args

If you want to pass arguments to the command, say you want your command to be helloWorld [name], anything you pass after the helloWorld command in the terminal, will…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@adamthewarrior
Comment options

Answer selected by m4tt72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants