-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
node_modules/ | ||
dist/ | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# CLI-TOOL | ||
|
||
## Description | ||
|
||
The *CLI-TOOL* package is a CLI tool that can be used to create a CLI tool in Node.js. It can be used to create a CLI tool in Node.js. It can be used to create a CLI tool in Node.js. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#! /usr/bin/env node | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const commander_1 = require("commander"); | ||
// Declare the progarm | ||
const program = new commander_1.Command(); | ||
// Aadd actions onth that CLI | ||
program | ||
.command("greet <string>") | ||
.argument("<string>", "string to greet") | ||
.option("-c, --capitalize", "capitalize string") | ||
.action((name, opts) => { | ||
const cap = opts.capitalize ? name.toUpperCase() : name; | ||
console.log(`Hello ${cap}`); | ||
}) | ||
.description("Prints a greeting"); | ||
program | ||
.command("add <numbers...>") | ||
.action((numbers) => { | ||
const sum = numbers.reduce((acc, number) => acc + number, 0); | ||
console.log(`Sum: ${sum}`); | ||
}) | ||
.description("Adds numbers and logs the result"); | ||
program | ||
.command("get-max-number <numbers...>") | ||
.action((numbers) => { | ||
const max = Math.max(...numbers); | ||
console.log(`Max: ${max}`); | ||
}) | ||
.description("Gets the max number and logs the result"); | ||
// Excecute the CLI with the arguments | ||
program.parse(process.argv); |