Commander.js - Working with Commands

Building Command Line Tools with Python, Julia and Nodejs Module 03 - Building Command Line Tools with Nodejs (JavaScript)
6 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€65.64
List Price:  €93.77
You save:  €28.13
£56.58
List Price:  £80.84
You save:  £24.25
CA$96.26
List Price:  CA$137.53
You save:  CA$41.26
A$109.08
List Price:  A$155.84
You save:  A$46.75
S$95.27
List Price:  S$136.11
You save:  S$40.83
HK$548.12
List Price:  HK$783.07
You save:  HK$234.94
CHF 63.72
List Price:  CHF 91.04
You save:  CHF 27.31
NOK kr771.14
List Price:  NOK kr1,101.67
You save:  NOK kr330.53
DKK kr490.05
List Price:  DKK kr700.10
You save:  DKK kr210.05
NZ$118.86
List Price:  NZ$169.82
You save:  NZ$50.95
د.إ257.05
List Price:  د.إ367.23
You save:  د.إ110.18
৳7,664.43
List Price:  ৳10,949.65
You save:  ৳3,285.22
₹5,835.09
List Price:  ₹8,336.20
You save:  ₹2,501.11
RM334.83
List Price:  RM478.35
You save:  RM143.52
₦90,777.03
List Price:  ₦129,687.03
You save:  ₦38,910
₨19,435.77
List Price:  ₨27,766.58
You save:  ₨8,330.81
฿2,575.67
List Price:  ฿3,679.68
You save:  ฿1,104.01
₺2,273.66
List Price:  ₺3,248.23
You save:  ₺974.56
B$364.16
List Price:  B$520.25
You save:  B$156.09
R1,350.44
List Price:  R1,929.28
You save:  R578.84
Лв128.28
List Price:  Лв183.27
You save:  Лв54.98
₩96,200.90
List Price:  ₩137,435.75
You save:  ₩41,234.85
₪263.23
List Price:  ₪376.07
You save:  ₪112.83
₱4,029.53
List Price:  ₱5,756.72
You save:  ₱1,727.18
¥10,822.20
List Price:  ¥15,460.95
You save:  ¥4,638.75
MX$1,196.86
List Price:  MX$1,709.87
You save:  MX$513.01
QR254.81
List Price:  QR364.04
You save:  QR109.22
P969.97
List Price:  P1,385.73
You save:  P415.76
KSh9,183.54
List Price:  KSh13,119.90
You save:  KSh3,936.36
E£3,382.61
List Price:  E£4,832.51
You save:  E£1,449.90
ብር3,968.10
List Price:  ብር5,668.96
You save:  ብር1,700.85
Kz58,581.63
List Price:  Kz83,691.63
You save:  Kz25,110
CLP$66,657.14
List Price:  CLP$95,228.57
You save:  CLP$28,571.42
CN¥506.67
List Price:  CN¥723.85
You save:  CN¥217.17
RD$4,155.65
List Price:  RD$5,936.90
You save:  RD$1,781.25
DA9,420.16
List Price:  DA13,457.95
You save:  DA4,037.79
FJ$159.39
List Price:  FJ$227.72
You save:  FJ$68.32
Q543.16
List Price:  Q775.98
You save:  Q232.81
GY$14,611.27
List Price:  GY$20,874.15
You save:  GY$6,262.87
ISK kr9,886.08
List Price:  ISK kr14,123.58
You save:  ISK kr4,237.50
DH707.48
List Price:  DH1,010.74
You save:  DH303.25
L1,253.52
List Price:  L1,790.82
You save:  L537.30
ден4,041.45
List Price:  ден5,773.75
You save:  ден1,732.29
MOP$563.44
List Price:  MOP$804.95
You save:  MOP$241.50
N$1,341.89
List Price:  N$1,917.07
You save:  N$575.18
C$2,586.83
List Price:  C$3,695.63
You save:  C$1,108.80
रु9,327.64
List Price:  रु13,325.78
You save:  रु3,998.13
S/260.57
List Price:  S/372.26
You save:  S/111.68
K265.99
List Price:  K380
You save:  K114.01
SAR262.56
List Price:  SAR375.10
You save:  SAR112.54
ZK1,793.08
List Price:  ZK2,561.66
You save:  ZK768.57
L326.81
List Price:  L466.89
You save:  L140.08
Kč1,658.72
List Price:  Kč2,369.71
You save:  Kč710.98
Ft25,891.40
List Price:  Ft36,989.30
You save:  Ft11,097.90
SEK kr763.84
List Price:  SEK kr1,091.25
You save:  SEK kr327.40
ARS$60,978.78
List Price:  ARS$87,116.28
You save:  ARS$26,137.50
Bs483.61
List Price:  Bs690.90
You save:  Bs207.29
COP$274,351.87
List Price:  COP$391,948.05
You save:  COP$117,596.17
₡35,072.06
List Price:  ₡50,105.09
You save:  ₡15,033.03
L1,724.15
List Price:  L2,463.18
You save:  L739.02
₲516,670.58
List Price:  ₲738,132.47
You save:  ₲221,461.88
$U2,687.21
List Price:  $U3,839.04
You save:  $U1,151.82
zł283.10
List Price:  zł404.45
You save:  zł121.34
Already have an account? Log In

Transcript

Now let's see some other stuff, in case you want to add commands to it. So there's going to be four commands. So how do you add commands to is going to be programmed? That command does the basic idea that we pass in your course. So let's make it as we did previously, this format, then I can supply the command I want to give, right? So let's give it a simple commandment.

Let's see, register. So there is a simple command. So if I save it now, and I come back and run the same thing that I did, you can still have our options, right in a new flow box. We have our options here. We still have our mass register, right? So I guess I want to add some description to we can just come back to that.

Then I can just add a description. Very interesting. So this can be the register user If I come back here, now this is empty, right? If I run it again, that will add that register user, which was totally different from this suit here, there's no register user. But here, our description has been supplied. Very interesting.

I can also add another one to it. Which is going to be any other stuff I want to do right so let's add our national to have gotten our command our description and let's add an action to the action is going to pick a function. So something like this who can make it simple in this particular format here, give me the function name, okay, just call me this particular function is applied the argument so let's give it like metal name. Then I'll paste it here to let it be console. dot log, the unless it is registering, registering, then I'll pass in the name that is being registered, which is going to be Oh, honey, right? Perfect.

So let's run it and see what you have so far. I come back and I close this one Come back to this pivot register. Now, because I want to register the name, I just go to the CMT register. That is a command in a capacity policy. So they're going to write all this particular information, very interested in it. With us all this stuff here, we have our new GS registered.

That was globally. So this is how it is. So this command is actually like a class, right, which has all of these things, we have commodity options, you have all of these individual stuff. Very interesting right out of the box, does able to give us XP, just as we learned earlier on, and is given that is supplied for us, registered user and description is totally fine. Now let's bring it on. So to bring this particular demo to actually print it out, you can just come back to this command here.

Then you pass it in here to what's called identify that this name, variable here is referring to this leap here. Let's save it and come back to the same place. And now if I run it, it's going to print it out of the screen. Right. So without this here, it's going to print out everything. Together with that details.

It's gonna see you, right. But for you to let it know that this name, or this name is very delayed here, just pass it inside this bracket. So it's good to understand that this particular name is in the pasty and the name being reflected. Very interested, right? So really strange. Very nice.

So that's how to work with commas. You can also check how to work with options. So let's see how to work with options. Now let's see how to add options to our commands. We have seen how to work with commands, like if you want to modify this particular need, right with an option to do so you can just come to the same place that we did the good option, right, then you can supply that particular option that you want it to be. So that option is going to be like this.

And as you learn that options are usually With no mandatory and you have a desktop, so let's go to the upper right now give it that option, it's very interested, then I can also supply the chatroom ID the long format, then the short format, the shoe period, then I can move on and give it a description. So let's go test this. So there's going to be upper case, right? Very interesting. So that is something very simple. So you can just make it like a pony to convert this into two upper, which in the last case can just come back to the simplicity I've done, then go with dot two, upper case.

Very interesting. So there is something very simple. So let's run it and see what you have done. Come back to this input, then I'll run the help. So if I run the help, I see that I have my register here. And I have my options and their name and under register, right, very interesting.

So to get more information from that particular receptor, just come to the register does this help Want to pray to God saved and above right so these are CLR register option and it is very interesting. Let's see how to work with it to get it to see that our options are here to get a description to go to run it so to run it we saw that running it was this month by Saudi registered the options in the name soon kicked out you can just come back to the same thing at the health supply the name there, so let's give it the name like let's see. I can I can just move on to jewel registering jaws will be converted to uppercase very, very interesting, right? Very nice. If I omit it is still going to wake because it's optional. Registering to write that is a big idea.

So that is how to work with commands and then how to create a simple CLA with managers. So in this session, we try to see how to work with options. So the basic idea that specify when to input any store commander with NPM, install commander right then after that you just going to require it imported by acquainted here, then go to quit variable core program, then it is going to create a simple basic information about it. Then you also want to work with command to just quit program to to command any supply DPS. Thank you for watching and see you in the next session. Stay blessed

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.