Let's continue adding in a little bit more configuration to our command.
Remember, we want to allow multiple different variations of this JDBC serve command to be executed.
So we should be able to allow a user to run just JDBC served by itself.
If they do so, we're going to make an assumption about the name of the file that we're going to store
all the user cells in.
We're also going to use some kind of default value for the port to run our server on as well.
But then we're going to also allow a ton of different variations of this command so user can run JDBC
serve and then provide a file name, daybook serve and then provide a specific port to run our server
on daybook, serve filename and port daybook, serve Dashty or JDBC serve booked up and then the port.
So what different variations here.
So we're going to write in a couple of different options to our command to tell Commander about all
these different possible variations.
The back inside of our editor.
We're going to first find command right here and inside of serve for that string.
Right after it, we will put in brackets file name like so.
So this is going to tell commander that there's going to be some optional value that a user is going
to provide here.
So it may or may not be present at some point in time.
We're going to have to also provide the default value.
We'll take care of that in just a moment.
Let's also add in an option to tell commander that we want or might receive a port option, so dash
dash port or just dash P.
For that, right after our description, we will add in option then instead of a string Kaspi bomber
dash dash port.
Angle, brackets, number.
Well, then put in a second argument as a string that is going to describe what this option is all about.
Let's say port to run, server on.
And then finally, we will provide a default value for it.
As a third argument to option, I'm going to put in four thousand five.
So that's going to be our default ports, water on.
You'll notice I'm adding that in as a string.
That is because whenever a user gives us command line arguments, they're always, by default treated
as a string, even if it looks like it actually is a number.
So we're going to make sure that whatever default value we are given or whatever value a user provides
to us, we're always going to treat it as a string or we're going to eventually pass it into a number.
Now, you might notice that in some places I'm using some square brackets and in others I'm using angle
brackets, square brackets are indicating to commander that this is an optional value and it may or
may not be present in brackets, indicate that this is a required value.
So if a user is going to provide the support option, they must provide a number to us as well.
All right, let's save this.
I'm going to flip back over and we'll do another quick test at our terminal.
Now back inside of our district.
We should have an updated index just filed right there.
So I should be able to run Noad Index serve.
And still see everything work as expected.
I should also be able to do a dash dash help and get some updated information about the different options
we can provide.
So now we have these different options around providing support.
And we're also told that option that we can provide a file name as well.
So how do we actually receive these different options and do something with them?
Well, for that, we're going to receive them as arguments into this action function right here.
So the first argument to this action function is going to be whatever optional arguments or required
arguments are passed to the original route command right here.
So in other words, the first argument is going to be our file name.
I'm going to provide a default value for this, so this is where we can set up a default value.
You're going to say that the user does not give us a default value.
We're going to assume that we want to save a listing of all their cells into a notebook file.
Then our second argument is going to be a object with all the different options inside of it.
We will put in.
Or how about just right now, we'll just receive, let's call it options.
We'll take a look at what that object actually looks like and then eventually just d structure out the
properties we actually care about.
So then rather than doing a simple console log right here, I'm going to try to console log out filename
and options.
Let's then save this back to the terminal and another quick test.
Now, I should able to do a node in index, just serve with.
Nothing, and we'll see that my default of notebook's was provided and I got a report of four thousand
five.
I should be able to do a serve with books.
And now my first argument is books, I should go to do a dash dash port of, say, 5000 and have that
now be my port.
I built to do a dash p.
Yep, that's my port, and then finally, I should be able to also list options before.
The book option as well, or really the argument if I put in Noad index dogs serve dash five thousand
and then that filename, it should still work as expected.
Yep, still does.
Remember, there's going to account for users possibly thinking that they can put in options before
the actual file name.
The commander is incorrectly interpreting all these different variations and parsing everything accordingly.
Finally, just one last very small variation I should be able to do.
A dash dash port equals five thousand.
Yep, that still works as well.
OK, so that's pretty much it.
You can tell that commander is really doing a lot of work here.
It is handling just about every corner case we can possibly think of and essentially parsing all the
different command line arguments and providing them to us as arguments.
To our action function right here, so let's take a quick pause right here, come back the next video.
We're going to finish up our SERP command and then move on to putting together our local API.