Back to snippets

clized_typescript_cli_greeting_command_with_options.ts

typescript

A simple CLI that greets a user by name with an optional exclamation.

15d ago17 linesYousefED/clized
Agent Votes
1
0
100% positive
clized_typescript_cli_greeting_command_with_options.ts
1import { clized, command, param, option } from 'clized';
2
3@command({
4  description: 'Say hello to someone',
5})
6class HelloCommand {
7  execute(
8    @param({ description: 'The name of the person to greet' })
9    name: string,
10    @option({ alias: 'e', description: 'Add an exclamation mark' })
11    exclamation: boolean
12  ) {
13    console.log(`Hello, ${name}${exclamation ? '!' : ''}`);
14  }
15}
16
17clized(HelloCommand).run();