Building CLI with Vorpal.js - Introduction

Building Command Line Tools with Python, Julia and Nodejs Module 03 - Building Command Line Tools with Nodejs (JavaScript)
12 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
€67.35
List Price:  €96.21
You save:  €28.86
£55.83
List Price:  £79.77
You save:  £23.93
CA$100.76
List Price:  CA$143.95
You save:  CA$43.19
A$112.23
List Price:  A$160.33
You save:  A$48.10
S$95.14
List Price:  S$135.93
You save:  S$40.78
HK$543.62
List Price:  HK$776.63
You save:  HK$233.01
CHF 63.04
List Price:  CHF 90.06
You save:  CHF 27.02
NOK kr797.48
List Price:  NOK kr1,139.30
You save:  NOK kr341.82
DKK kr502.49
List Price:  DKK kr717.87
You save:  DKK kr215.38
NZ$124.10
List Price:  NZ$177.29
You save:  NZ$53.19
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.18
৳8,361.55
List Price:  ৳11,945.58
You save:  ৳3,584.03
₹5,962.79
List Price:  ₹8,518.63
You save:  ₹2,555.84
RM314.04
List Price:  RM448.65
You save:  RM134.61
₦108,335.42
List Price:  ₦154,771.52
You save:  ₦46,436.10
₨19,495.71
List Price:  ₨27,852.21
You save:  ₨8,356.49
฿2,390.81
List Price:  ฿3,415.60
You save:  ฿1,024.78
₺2,467.44
List Price:  ₺3,525.07
You save:  ₺1,057.62
B$434.14
List Price:  B$620.23
You save:  B$186.09
R1,296.68
List Price:  R1,852.48
You save:  R555.80
Лв131.68
List Price:  Лв188.12
You save:  Лв56.44
₩102,198.93
List Price:  ₩146,004.73
You save:  ₩43,805.79
₪256.56
List Price:  ₪366.53
You save:  ₪109.97
₱4,090.81
List Price:  ₱5,844.26
You save:  ₱1,753.45
¥10,994.99
List Price:  ¥15,707.80
You save:  ¥4,712.81
MX$1,408.98
List Price:  MX$2,012.91
You save:  MX$603.93
QR255.09
List Price:  QR364.43
You save:  QR109.34
P967.82
List Price:  P1,382.66
You save:  P414.84
KSh9,046.20
List Price:  KSh12,923.70
You save:  KSh3,877.50
E£3,562.49
List Price:  E£5,089.49
You save:  E£1,527
ብር8,907.19
List Price:  ብር12,725.10
You save:  ብር3,817.91
Kz63,830.88
List Price:  Kz91,190.88
You save:  Kz27,360
CLP$69,323.69
List Price:  CLP$99,038.09
You save:  CLP$29,714.40
CN¥510.80
List Price:  CN¥729.75
You save:  CN¥218.94
RD$4,245.36
List Price:  RD$6,065.06
You save:  RD$1,819.70
DA9,465.07
List Price:  DA13,522.10
You save:  DA4,057.03
FJ$162.39
List Price:  FJ$232
You save:  FJ$69.60
Q539.11
List Price:  Q770.19
You save:  Q231.08
GY$14,638.77
List Price:  GY$20,913.42
You save:  GY$6,274.65
ISK kr9,772.70
List Price:  ISK kr13,961.60
You save:  ISK kr4,188.90
DH703.98
List Price:  DH1,005.73
You save:  DH301.75
L1,291.33
List Price:  L1,844.84
You save:  L553.50
ден4,143.97
List Price:  ден5,920.21
You save:  ден1,776.24
MOP$559.97
List Price:  MOP$800
You save:  MOP$240.02
N$1,289.45
List Price:  N$1,842.15
You save:  N$552.70
C$2,574.80
List Price:  C$3,678.44
You save:  C$1,103.64
रु9,534.71
List Price:  रु13,621.60
You save:  रु4,086.89
S/260.99
List Price:  S/372.86
You save:  S/111.86
K283.85
List Price:  K405.52
You save:  K121.66
SAR262.91
List Price:  SAR375.60
You save:  SAR112.69
ZK1,936.45
List Price:  ZK2,766.47
You save:  ZK830.02
L335.12
List Price:  L478.77
You save:  L143.64
Kč1,694.03
List Price:  Kč2,420.15
You save:  Kč726.12
Ft27,771.44
List Price:  Ft39,675.18
You save:  Ft11,903.74
SEK kr774.38
List Price:  SEK kr1,106.30
You save:  SEK kr331.92
ARS$71,792.58
List Price:  ARS$102,565.23
You save:  ARS$30,772.64
Bs484.55
List Price:  Bs692.24
You save:  Bs207.69
COP$307,165.41
List Price:  COP$438,826.54
You save:  COP$131,661.12
₡35,530.54
List Price:  ₡50,760.09
You save:  ₡15,229.55
L1,777.33
List Price:  L2,539.15
You save:  L761.82
₲546,250
List Price:  ₲780,390.60
You save:  ₲234,140.59
$U3,115.91
List Price:  $U4,451.49
You save:  $U1,335.58
zł287.82
List Price:  zł411.19
You save:  zł123.37
Already have an account? Log In

Transcript

All right, so welcome back. Again, my name is Jessie. And in this session of the course, we're trying to see alanda framework to build ci tools. So this from Cova power superpower allows us to build both interactive and non interactive ci. So let's see what I mean. So if you work with node, I go to the node repple.

That's it. And this is giving us something very interesting. I dislike interactive and as well as a repple. So in case you want to build a CI, that gives you the option of working interactively inside your terminal can use papo. So let's go out and see how to work with it. There's going to be is it and then how to work with it just go to let's create a folder called power to vapo.

Then our move inside my apologies. In addition to initialize, I'm going to create NPM in it. That's why then you just move straight away to it right to create a package JSON file, or you can just go straight away with the long format by digit format to do that, means that I do want a prompt, I want to just create something out of this using the default, right does it add this finish everything if it has created a package or JSON file, now let's add football to B. So to install ballpark, just go with npm install that just save, then we just go with papa, papa is going to add more power to it and then you could add more power to our packet or JSON file. So if I come back to my bubble, send my packet to JSON file. This is the busy stuff here, right?

Add Papa D. So now let's make some changes. I'll just change this one to see a lot of GS analysis created a particular file called sila GS or just see the CLI this to say the same location to help our create my clr.gs right that is the basic idea supposed to be Gs. So with Bob or you can just with us either interactive or Non interactive, right is quite cool. So you have concrete, both interactive and non interactive CLR Rich vapo. So let's see how to first of all work with the non interactive, then you see how to work with a interactive. So let's start with it.

So first of all what is installed I'm going to add some basic stuff to the base that we just imported to cost 24 file, then I'm going to go to require, and I pass in my package, this pop up, right, then I need to put another function that is how to work with vapo. Now I'm going to close this particular stuff here. Now let's see how to work with this. So the basic syntax for working with purple is that we are going to go with specify a command. Right? Then when you go with the command and just move on to it with that optional argument.

There is going to be an option argument. Then in case you also want to do require that ranges go with this is supposed to be this required Right, an NF runner one just in case you want to pick, this is for optional, and it's for quite all positional position. All right, very interesting. I don't know how you position a position, that is a three should understand this position this. So with this command anytime you're given an option admit it must be inside this particular body right inside this parenthesis. And this is for positional unit square bracket.

So let's have this in mind. Now let's move on and create a simple program. So by now that's finished, it's almost done. So I'm going to create a simple program for that there's going to be something very simple, but we will pop then I'll just go with the normal format. So let's come to command and I passing my command so let's give a simple command called login with the command name, so let's go to login, right perfect. So I agree this I can now move on to the next one and give the description so it is going to be a description that's what is the description.

Just like in case we're working with command right description, then just go with the say login to view that the basic idea behind what you have done so far, then we can just move on and then add some other stuff to it, which is going to be like the action that you want to apply. So is going to be action action in our passing my function, then let's make it an anonymous function, then here is going to be the argument. So let's put that x then a callback. What about Papa is that it usually relies on the callback also so should always bring the callback no matter the case right so you can make it as callback or CB in here you want then if you want to print out the result just go with it they can just go with rapa dot Tim, come on.

Come on. To log, right, which is a long format, but let's go with the simple format of this. So this dot log, then are passing my value, right? So let's say I want to say hello to a patient that has logged in. And we'll come back and we'll come right to the patient. So then I can go with the x dot, whatever pace, whatever to know what to do.

Right? as the liquidus. Excellent. So we have created something very simple, but for it to work, you have to bring the callback do I can go to two callback and that is Oh, so this is simplest we have created a command with vapo this four command question. Now for us to work on it. As I said, we can either make it interactive or non interactive.

So to make it non interactive, you just have to come back to down here, then just going to devote power to the pass in passing your process as you laid out, right We'll make it non interactive, right, this command will make it non interactive select a space. Let's give it a name is non interactive. So I'll see this if it's right. So, this is going to make it non interactive so as to make it process right then unless right and see. So if I come back to this place, the Spanish magic LS CFR here. Now I can run it to load the ACL, I agree that that hope is going to lift the whole for so this is going to make it non interactive, right?

Very, very interesting. So to work on it, I can just go with the same option that I have here. This close this is a command is going to give to us going to list the various commands we have our log in here, then log into view, which is a description which we supplied here. So in case I want to actually add o which is going to be this option, and I pass in a login and I pass in my family let's see. Just do it. This now going to print that battle on Hello Welcome, Derek, good to pass the validate.

So hello and welcome, then the value, right. So that is something very interesting. And it's how to work with Bob, this is non interactive and get out to make it interactive, I can just go with the same option or comment this one out. Now this is going to be the format for day two, to get the interactive just going to pass in this comment. Well, Paul, that's good supply the delimiter, right, there's going to be delimiter, the delimiter How is going to appear, then I can just pass in my value. So let's use $1 sign for a delimiter can be any name, then I just need to pass in the the the simplest, right?

Perfect then I can just close it. So this is going to make it interactive. If I say this one, and I come back here, and I run the same command that I have for now if I run it without any argument to give it as interruptive for us defense to the now is bringing this delimiter here, which is referring to the delimiter. I get to work on it and it's going to help agree to it's going to list the help command for us. Right? Very interesting.

So we get to work with looking I just go to login, which is quite cool. Like I put this into Ninja, there's going to print hello and welcome with the option, right that is for the non interactive for the interactive to to work with non interactive, just bring this block option you pass it right. But to make it interactive, you just bring this option. Now we can change this one and make it better. So this is okay, you can just make it like Seelye. So, feel like right, something like that.

If I save it, and let's add some basic stuff to it. So to add some basic stuff like that it would get given us the option, right there's not giving us any details any value. So we have to get the value from this particular option and just pass it here. So let's first of all, understand that you can pass in our option argument here just as we did, you can just come back to the same place that I have In passing that particular option argument, so let's make it like this. So let's What does he need to budget pass, and this is an MBA to understand that this username is going to be what's going to be reflected on. So I'll just come back to the same place and go to user.

Right? Because from here, you realize that this was optional. So let's save it. And then let's run it again. So Oh, as it formed it. If it were isolated, they believe it.

So let's run it again. So it's going to be my node and the CLA GS, latest. Now, we're going to change it to GBA this particular delimiter here, right the ally. Very interesting. And I can actually click on the Help with keep us the help. So in case I want to check for the login, I can just go to login.

They're not giving us the option of having a username that is going to be an option argument. So you can get a pass in a name here as we did go into Hello and welcome, Jessica, because it's breaking, it's been identified that particular value here right very interesting. So, that is how to work with double variable interest to the basic idea that it is going to install vapo then create a constant variable here in which we require or imported a particular package, then to create a simple command just go to the command give the command name and then the argument right it must be this is going to be optional commit, then the description, then it actually is going to allow us to come back to the same thing. Yes, in a passing right, if I save it, and I come back to the same thing here, this is from it.

And the next point again, if I write again, now I can use this alias as as an alternative, right? That is the basic idea. And then we must always remember the callback function, because without it is not going to break. The callback is going to help us if I agree, the hope is that we have it here. I can Escuela de l, the alias, then is going to make a good L and I pass in a name like say, David. That is working perfectly right?

So use the alias, which is the short format or the command. So if I go with the command as login it's also going to make so login. Is he married? Is it Hello and welcome Mary right, it's working perfectly. Let's how to work with pop out. So this is for the interactive option.

And to get the non interactive just go with this particular option. Very, very interesting to get help for that can also do login, then hope is going to bring it out to the drinking. But to get that he'll just go to then login, right you just turn it, it's going to list it perfectly for us, right? We just tend help then you supply the command is going to give us the information about it. So this option and this is what is taken very, very interesting. So that is the basic idea about how to work with papa.

Now let's see some other aspect of it in the nisshin

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.