Building CLI Tools with Argv

Building Command Line Tools with Python, Julia and Nodejs Module 03 - Building Command Line Tools with Nodejs (JavaScript)
13 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.26
List Price:  €93.23
You save:  €27.97
£55.95
List Price:  £79.94
You save:  £23.98
CA$95.75
List Price:  CA$136.79
You save:  CA$41.04
A$107.23
List Price:  A$153.20
You save:  A$45.96
S$95.15
List Price:  S$135.94
You save:  S$40.78
HK$547.94
List Price:  HK$782.80
You save:  HK$234.86
CHF 63.91
List Price:  CHF 91.30
You save:  CHF 27.39
NOK kr766.40
List Price:  NOK kr1,094.90
You save:  NOK kr328.50
DKK kr486.75
List Price:  DKK kr695.39
You save:  DKK kr208.64
NZ$117.46
List Price:  NZ$167.81
You save:  NZ$50.35
د.إ257.06
List Price:  د.إ367.25
You save:  د.إ110.18
৳7,670.29
List Price:  ৳10,958.03
You save:  ৳3,287.74
₹5,832.01
List Price:  ₹8,331.80
You save:  ₹2,499.79
RM334.37
List Price:  RM477.70
You save:  RM143.32
₦88,678.72
List Price:  ₦126,689.32
You save:  ₦38,010.60
₨19,457.85
List Price:  ₨27,798.13
You save:  ₨8,340.27
฿2,591.43
List Price:  ฿3,702.20
You save:  ฿1,110.77
₺2,274.88
List Price:  ₺3,249.97
You save:  ₺975.09
B$360.25
List Price:  B$514.66
You save:  B$154.41
R1,330.75
List Price:  R1,901.16
You save:  R570.40
Лв127.68
List Price:  Лв182.41
You save:  Лв54.73
₩96,191.02
List Price:  ₩137,421.64
You save:  ₩41,230.61
₪265.67
List Price:  ₪379.55
You save:  ₪113.87
₱4,044.82
List Price:  ₱5,778.57
You save:  ₱1,733.74
¥10,886.62
List Price:  ¥15,552.99
You save:  ¥4,666.36
MX$1,193.70
List Price:  MX$1,705.36
You save:  MX$511.66
QR254.90
List Price:  QR364.16
You save:  QR109.26
P969.33
List Price:  P1,384.82
You save:  P415.49
KSh9,413.65
List Price:  KSh13,448.65
You save:  KSh4,035
E£3,352.26
List Price:  E£4,789.16
You save:  E£1,436.89
ብር3,973.96
List Price:  ብር5,677.33
You save:  ብር1,703.36
Kz58,616.62
List Price:  Kz83,741.62
You save:  Kz25,125
CLP$66,678.07
List Price:  CLP$95,258.47
You save:  CLP$28,580.40
CN¥507.14
List Price:  CN¥724.52
You save:  CN¥217.38
RD$4,110.44
List Price:  RD$5,872.31
You save:  RD$1,761.87
DA9,401.90
List Price:  DA13,431.87
You save:  DA4,029.96
FJ$160.42
List Price:  FJ$229.18
You save:  FJ$68.76
Q543.26
List Price:  Q776.12
You save:  Q232.86
GY$14,630.45
List Price:  GY$20,901.55
You save:  GY$6,271.09
ISK kr9,795.80
List Price:  ISK kr13,994.60
You save:  ISK kr4,198.80
DH709.23
List Price:  DH1,013.23
You save:  DH303.99
L1,246.59
List Price:  L1,780.93
You save:  L534.33
ден4,020.35
List Price:  ден5,743.61
You save:  ден1,723.25
MOP$563.94
List Price:  MOP$805.67
You save:  MOP$241.72
N$1,340.22
List Price:  N$1,914.68
You save:  N$574.46
C$2,572.43
List Price:  C$3,675.06
You save:  C$1,102.63
रु9,316.74
List Price:  रु13,310.19
You save:  रु3,993.45
S/259.29
List Price:  S/370.43
You save:  S/111.14
K265.67
List Price:  K379.55
You save:  K113.87
SAR262.50
List Price:  SAR375.02
You save:  SAR112.51
ZK1,825.88
List Price:  ZK2,608.51
You save:  ZK782.63
L324.76
List Price:  L463.96
You save:  L139.20
Kč1,644.30
List Price:  Kč2,349.11
You save:  Kč704.80
Ft25,615.12
List Price:  Ft36,594.60
You save:  Ft10,979.47
SEK kr760.35
List Price:  SEK kr1,086.27
You save:  SEK kr325.91
ARS$61,118.20
List Price:  ARS$87,315.45
You save:  ARS$26,197.25
Bs482.97
List Price:  Bs689.99
You save:  Bs207.01
COP$272,384.35
List Price:  COP$389,137.18
You save:  COP$116,752.82
₡35,055.79
List Price:  ₡50,081.85
You save:  ₡15,026.05
L1,725.31
List Price:  L2,464.83
You save:  L739.52
₲519,197.15
List Price:  ₲741,742.01
You save:  ₲222,544.85
$U2,684.12
List Price:  $U3,834.62
You save:  $U1,150.50
zł281.58
List Price:  zł402.27
You save:  zł120.69
Already have an account? Log In

Transcript

All right, so welcome back again. So in this particular session, we try to see how to build our CI tools without using an external package or library. So let's see how to work with it. But first of all, it gives you to have no GS can just go to the official website, and this node j.org, then you can download it for your system, right? So this is for Windows, there's also support for Macintosh, Linus and interest. So you can just choose the LTS format, or the current format, then just install it unless you're too offended.

So I'll come back to our working area is that on Moodle three, we have nothing so I'm just going to create a simple file. Simple folder, so we're left with an empty URL. Let's go that's x CLR for us tutorials, if it is what you are doing, so just move inside of x. That's what we reckon, isn't it? So let's go to Buddha OC like without any external pocket or disproof of this, and a new try and see how to work with this. I'm just going to create a file here inside our x tutorial.

X to use. The name of the file is going to be Sierra Lie this quarters inside here. This give it an MSc li.js. Right? But je s destination must be Chase, not J. All right.

Very interesting. That is code that we need. So first of all, we have created something very simple. But to be able to work with our, to critically alight the standard ways to initialize that particular folder, which is going to create a package JSON file, which is going to include all the various information you need, which is very useful in case you want to deploy your app, right. So let's go to liquid and just going to go with NPM in it, to initialize that particular folder. There is what give us a prompt that is going to ask us some basic questions that we need to do the prompt.

So that's going to give us the package name. So let's go with the same stuff. The Division 0.0 1.01 right, then a description so look for that burden. Let me spell it here. Gordon, CLS ally tooth in GS Right the entry point is correct, the CL IDs just get together we are going to be omitting the sauce. But in production system, you can just place these things in a queue as can be vcli and then load purchase, right something like that.

So the I can just pass in your name. And that is going to give you another information about all that you have entered. If it didn't find a school it Yes, if you agree with it, it is going to create initialize that particular folder. So in a previous I said realize that there was nothing here, but after you have initialized that particular project, or that particular folder, you get this lie right me that you have initialized it has given us a particular vision. Very interesting. So let's see how to work with it.

So it's going to create a package JSON file. So this packet dot JSON file is going to contain all the information about what you entered. Welcome back to the same place 123 x Then packages info, I can see that I have all my viewers information day to name is day, the patient and description and you can actually change this stuff here. Very interesting. So this is very, very useful when you're trying to deploy up or give it to someone to use it. Let's see how to build a simple ci from within no GS without any SNR package, I'm going to go with console dot log, then I'll go with process dot v. So this arg V is argument vector, right?

Is a demand vector to augment vector as we learned in previous sessions that augment vector x v means vector does the mean of the meaningful x V is going to collect a vector, or an array, or a list of all the arguments. That is the basic idea, right? That's the basic idea behind augmentative to JSON to call it in a number of arguments inside an array or inside a vector. So let's run this cluster. That you're done. If I save it, and I come back to the same place, let's run node, which is going to be the program or the interpreter, then it's going to go into our runtime, then CLS or undefined, that's that's given us this particular array.

So, this is a list and then if that is listed given as a first name, so, this is the particular program that is running referring to this node right, that is the program itself that is running this CLR then the next one is going to be the file itself right. So the location of this particular file, so this file is found in this particular location. So you can see that this location here, it is the master location here, right to get over this very, very interested then that is Oh, so in case I add another value to it, you see Hello. It is going to create another argument vector or a vector or a list of all of these things together the word hello. Separate Hello is the two is adding to it. The same way if I come back again in a lesson Add to 123, this is going to add it to us is going to collect on limited number of arguments, right.

So far, it's going to pass it as a basic idea behind the XP. Very, very interesting. So in every, almost all the CLS we bought in this particular process, actually will be very, very useful, right? Very interesting. That is something very busy. Now let's see how to build it.

So you can see from here that you have our node runtime, our CI, and now Hello. And then based on the anatomy of us, let's recap on the anatomy of a CI. So this is going to be done at UCLA, as you have learned. So for the anatomy vcli is going to be our CLR, then we're going to have our command or option. Right, then we're going to keep our body as the basic anatomy of every CLA that you have learned so far, very interested. So based on what you have done, so this is going to be the CLR itself.

And then this is going to be the command and is going to be the parameter to pass an audit value. So let's try and build something from it. So this is Good. This is V, right? Again, beta two, since it's a list of an array, it is counted from zero. And up was not from one because the basket, let's see how, how to work with it, to be able to understand it variable to create our own CLS.

I'm just going to go with this, just call the cost constant. Let's go to one of our runtime IoT, right? Then I'll just go with this runtime as my process. process, but equity and main data and I'm going to pick the face value, right? That is going to be our runtime, right? This is going to be around type or interpreter anyhow you call it very interested.

Then in this one is going to be our CLA. CLA is going to be our process. But then this is going to be one right then in this one is going to be our command to cost command Got process, but actually, which is going to be isoform. This can see that we have our runtime. So that is a programming. So if this Node JS runtime or no GS interpreter, any high quality, but in this case is a runtime, then we have our program itself, the CLA program itself, then you have the command, query option, then you have Power BI.

So if I come back again, and let's go with our cost. So let's say values to be process, admin Victor, in our passing topics, global mastery. So that is the basic idea behind what actually happens if I save it. Now I can close everything out. So console dot log. So this is going to be our runtime or interpreter.

That's going to be 400. Right? Very interesting in our passing my body, which is going to be my runtime. So let's expand it to the cathedral, get interested or copy the same thing here, duplicate it for the next one for the next one. So this is going to be for our CLA self. So that's one this is this will be for the Sierra right should I do to understand that this is actually the program itself, the CLS program that you have created, then then this one's going to be for our command.

The command is purely to this one, not too much of that is going to be Command Option gives you an option, then this will be tune in this is going to be value three. So this is going to be all the other stuff that is going to follow value what you want to do, right, which is usually a nice way to very interesting. So we'll change this one to our CI and this is going to be for our common dentists Last one will be for buddies. Very interesting. Right? So let's see what else run what you have done so far.

I'll come back to this please. So we have a good Yes, Eli Hello 123. If I run it again, I good to see variable in a very nice format this we can see from here that our runtime or the beta is zero, it is the Node JS program, right, as you can see from this particular stuff here, then the CLR program is one and it is this particular option. Right? That is a fallacy that is being run, then the command is the Hello, as you can see here. And then the 123 is it was going to suffer in the same way if I run something like this.

It gives you a run NPM and get installed by the lessee install a custom CLR right, it's going to run the same way to consider this install. It's going to be the command as you can see from here, this is still here. It's got to be the common from the right to very interested in values is going to be there concepts here to read. So if a Node JS itself, right, right, very, very interesting. That is the basic idea about working with XP. So with this article, you can build your own custom CLA haven't understood the previous positions.

And let's see how to build a simple CLR. From that, right? So there's going to copy this one into another one, so that you can use it as storage. So let's call this one, tax, the cla.gs. Right, this is the old one in our list, change and modify this. So I'm just going to uncomment all of this out.

We have our program, we have our runtime, everything is working. So let's comment this one out, or take it out. So this is going to be our command, right? So we know that two is our command, right? As you can see here, I can use it to do some interesting stuff. So let's see how to work with it.

So it's going to be very simple. I'm going to say that if my command if my command is equal to something, so we can use that conditional to work on it is going to be if our command if this is quoting something like C, right or greet, as contrasted with E, that is the case, I want you to do something else. What do I want you to do? How to console dot log, the particular value. So let's go test. Good morning.

Good morning, right? Very interesting, then I can pass in the attorney, that is going to be the name they want to pass. So good morning, then Dennis needs to relate here that it is going to be their value. So their value was three, right? So we can just go into sentinel value to all can just guess passing the test of us process. The X v. and everything from three up was right, or two Episode Three is this.

I see this one now in this right again, come back here. And like I just come back to the theme today. We have that sci fi movie. It's cute. JOHN, good to present it to us. So good morning, john.

Very, very interesting. So by that you're able to greet or Seelye to come then take retweeted the comment, then john, if it's if that particular command is equal to do it, then say, Good morning, john. Right? If or else you can also do the next one, just as we wish, as many as you want it to be the basic idea about how to build a simple CLR with XP, so we can just use this one to do a little snippet. This is not the best, right in this case, I make a mistake here. You cannot get impatient information.

If I do this, look and get information just go to print version so I can actually create another one like this. Seems to find that I did to go see if I can just come on. Let's go to vision. Then I'm going to print out division to console dot log which is going to be Particular CLR version 0.0 point 01. Right. This is quite simple and quite interesting.

So I come back here and I save it, you now have to come back around again, go to print CLR basically replace the one. So that is how to build the CLR using IP. So this is interesting to squid, but to take you a lot of time, right. So let's see in this session how to use some other external libraries to build our own custom COI. Thank you for watching and CDNs session stablest

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.