We've now got a pretty reasonable set up with Lerner inside of a project, so we're not going to turn
our attention back over to actually implementing different portions of our app.
The first portion that we're going to focus on is the so remember, our Seelie is going to be a program
that we want a user to run from their terminal.
So at some point in time, we're going to expect user to run a command like daybook server or something
very similar.
When a user runs this command, we're going to run the code inside of our CLIA package.
And inside that package, we're going to have some amount of code that is going to start up our local
API.
Now, you might recall that whenever we run JDBC Reserve, we might also want to allow a couple of optional
arguments to be passed along with his command as well.
So, for example, remember, we have said that whenever a user starts to change some cells inside the
browser, we want to somehow take that information, take that text, take that code and persistent
to a file on the user's hard drive.
And we have said specifically that we want to save it into a file so the user can very easily share
that file with other people or committed to get or whatever else.
So as a part of our Seelie, we might want to allow a user to specify exactly what file they want to
open up to get a list of cells from or to save cells into.
So we might want to allow a little variance on this command, maybe something like JDBC serve and then
some file name like say, maybe notebook.
So if a user ran this command, that would mean that we would want to open up the notebook as file inside
the current directory, see if there is already a list of cells saved in there.
And then otherwise, if a user ever changes any code or text inside the browser, we're going to save
the list of cells back into this notebook as file.
And remember, there's nothing special about the name notebook's.
This can be any JavaScript file name that we can possibly imagine.
So it can be notebook or book or my notes or whatever else.
In addition, there's another variant to the book of command that we might want to enable whenever we
run this command.
We're going to start up that local API, which is going to be the server that is going to actually save
information into this my notes file or whatever we end up calling it, that local API has to be running
or listening for traffic on a very specific port on the user's machine.
And maybe we want to allow a user to customize that port.
So maybe another variant of this book server command would be something like my notes, James Dash Dash
Port and then the port that the user wants to run the local API on.
So in this case, we would start up the local API on 30 50 instead of whatever default we decide to
use.
So at this point time, I'm trying to kind of communicate here is to say there are several different
variants of the books of command that we eventually want to implement.
We want to allow Gebo excerpt to be ran by itself with a file name, with a file name and a port, and
maybe also with just a port by itself.
So something like daybook serve Port 30 50 so that we've got many different variants of this command.
So whenever we start to run our Seelie, we need to figure out how to read in these different command
line arguments and then customize our program in a very specific way.
So to understand how to read in command line arguments, this might be something you are already familiar
with, but let me just give you a very, very quick reminder.
We're going to do a very quick little test here back inside of my coat, Ed. I'm going to find my route
project directory.
And inside there, I'm going to make a new file called Test.
Inside this file, I'm going to add in one line of code UNCLOG process, dot RGV process is an array
of strings.
Inside of that array is a list of all the different options that are provided to our program whenever
we run this test.
JS file process is automatically provided to us by node itself.
Let's save this file very quickly and then going to go back over to my terminal and try to run this
file with a couple of come in line arguments.
OK, so there's the test case file, I'll do a node asks and I'm going to add in my notes and dash dash
port 30 50 like so.
Now, when I run this, I'll see the contents of that process array, the first line right here is the
path to the node executable on your machine.
The second element, I should say, the first element, the element at index one is the path to the
file that we executed.
And then we were given a list of all the other command line arguments that are provided to us.
So you and I could try to write out a little bit of code that takes a look at these different elements
right here and then use these different elements to customize how our program works.
So if we have some file mentioned right here, clearly that would mean that we want to open up the my
notes, not just file and find a list of cells in there or something like that.
And then if we see the dash dash port, we could try to find the number right after it and make sure
that our API listens on that port.
Now, we could definitely try to write out all this logic ourselves to look at this process, the array.
But we would very quickly get into a little bit of trouble.
Remember that in general, there are several different kind of assumed variations of many different
commands that a lot of different engineers are going to assume just work.
So, for example, many engineers would assume that Dashty support space 30 50 is equivalent to 40 equals
30 50.
But if I run that, that dramatically changes the process, aragvi array.
So if we were going to manually process this array right here, we would have to kind of accommodate
or write out some logic to accommodate for the two different variations of providing aiport option.
In addition, many engineers generally assume that you might be able to provide different options in
any order when you are running a command.
So, for example, another engineer might assume that they could put in a dash dash port right there
of 30 50 and then the name of the file they want to open.
Well, if we run that once again, the order of the process RGV array has changed and again, we probably
don't want to have to write out really exhaustive logic to figure out all these different variations
of order rather than trying to write out our own custom man line implementation and try to read in all
the different variations of mainline arguments.
We're going to instead use a library to do it for us.
The library we are going to use is called Commander and we actually already installed that into our
Seelie project a little bit ago using llena.
So let's go take a look at some documentation around, Commander, very quickly, back inside my browser,
I'm going to go to NPM Jase's Dotcom and search for commander.
This is a library that is all about helping you build out command line interfaces, so pretty much doing
exactly what we just described, reading in different commands.
We're trying to run and then reading in different options we might provide.
If you want to, you can take a quick look at the documentation here.
But I'm going to be honest with you, there is a tremendous amount of documentation and it's rather
challenging to read through all of it in one go.
So this is one of those scenarios inside this course where we're going to come back the next video and
we're pretty much just going to say, hey, here's how you make use of commander.
So we're not really going to focus too much on the documentation.
I'm just going to give you a very direct explanation of do exactly this.
Here's a good pattern to follow, and we're pretty much going to run with that.
OK, so the last thing I want to do is just very quickly go back over to my editor and delete that test
file.
All right, so let's take a pause right here.
When we come back in just a moment, we'll start writing out some code inside of our Seelie package.