@anishaa13/anishaa13-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +38 -0
  2. package/package.json +18 -0
package/index.js ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+
3
+ const {program} = require("commander");
4
+
5
+ program
6
+ .command("greet <name>")
7
+ .action((name) => {
8
+ console.log(`Hello ${name}`)
9
+ })
10
+
11
+ program
12
+ .command('calc <n1> <n2> <n3>')
13
+ .option('-a, --add', "addition")
14
+ .option('-s, --sub', "subtract")
15
+ .option('-m', "multiply")
16
+ .option('-d', "divide")
17
+ .action((n1, n2, n3, options) => {
18
+ if (options.add){
19
+ console.log(Number(n1)+Number(n2)+Number(n3))
20
+ }else if(options.s){
21
+ console.log(Number(n1)-Number(n2)-Number(n3))
22
+ }else if(options.m){
23
+ console.log(Number(n1)*Number(n2)*Number(n3))
24
+ }else if (options.d){
25
+ console.log(Number(n1)/Number(n2)/Number(n3))
26
+ }
27
+ })
28
+
29
+
30
+ program
31
+ .command("joke")
32
+ .action(async () => {
33
+ const data = await fetch("https://official-joke-api.appspot.com/random_joke")
34
+ const joke = await data.json()
35
+ console.log(joke)
36
+ })
37
+
38
+ program.parse(process.argv);
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@anishaa13/anishaa13-cli",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "keywords": [],
9
+ "author": "",
10
+ "license": "ISC",
11
+ "description": "",
12
+ "dependencies": {
13
+ "commander": "^14.0.3"
14
+ },
15
+ "bin": {
16
+ "anishaa13-cli": "./index.js"
17
+ }
18
+ }