1
00:00:00,900 --> 00:00:03,810
Let's continue adding in a little bit more configuration to our command.

2
00:00:04,230 --> 00:00:08,910
Remember, we want to allow multiple different variations of this JDBC serve command to be executed.

3
00:00:09,370 --> 00:00:12,560
So we should be able to allow a user to run just JDBC served by itself.

4
00:00:12,720 --> 00:00:16,650
If they do so, we're going to make an assumption about the name of the file that we're going to store

5
00:00:16,650 --> 00:00:17,890
all the user cells in.

6
00:00:18,240 --> 00:00:21,750
We're also going to use some kind of default value for the port to run our server on as well.

7
00:00:22,410 --> 00:00:27,920
But then we're going to also allow a ton of different variations of this command so user can run JDBC

8
00:00:27,930 --> 00:00:33,570
serve and then provide a file name, daybook serve and then provide a specific port to run our server

9
00:00:33,570 --> 00:00:42,170
on daybook, serve filename and port daybook, serve Dashty or JDBC serve booked up and then the port.

10
00:00:42,930 --> 00:00:44,480
So what different variations here.

11
00:00:44,610 --> 00:00:48,870
So we're going to write in a couple of different options to our command to tell Commander about all

12
00:00:48,870 --> 00:00:50,490
these different possible variations.

13
00:00:51,220 --> 00:00:52,440
The back inside of our editor.

14
00:00:52,860 --> 00:00:57,300
We're going to first find command right here and inside of serve for that string.

15
00:00:57,300 --> 00:01:01,810
Right after it, we will put in brackets file name like so.

16
00:01:02,550 --> 00:01:07,530
So this is going to tell commander that there's going to be some optional value that a user is going

17
00:01:07,530 --> 00:01:08,210
to provide here.

18
00:01:08,220 --> 00:01:10,850
So it may or may not be present at some point in time.

19
00:01:10,890 --> 00:01:12,960
We're going to have to also provide the default value.

20
00:01:13,230 --> 00:01:14,540
We'll take care of that in just a moment.

21
00:01:15,810 --> 00:01:22,170
Let's also add in an option to tell commander that we want or might receive a port option, so dash

22
00:01:22,170 --> 00:01:24,010
dash port or just dash P.

23
00:01:25,070 --> 00:01:32,010
For that, right after our description, we will add in option then instead of a string Kaspi bomber

24
00:01:32,450 --> 00:01:33,740
dash dash port.

25
00:01:34,670 --> 00:01:36,290
Angle, brackets, number.

26
00:01:37,500 --> 00:01:42,030
Well, then put in a second argument as a string that is going to describe what this option is all about.

27
00:01:42,460 --> 00:01:44,940
Let's say port to run, server on.

28
00:01:46,020 --> 00:01:48,720
And then finally, we will provide a default value for it.

29
00:01:49,910 --> 00:01:53,930
As a third argument to option, I'm going to put in four thousand five.

30
00:01:54,080 --> 00:01:56,360
So that's going to be our default ports, water on.

31
00:01:57,100 --> 00:01:59,090
You'll notice I'm adding that in as a string.

32
00:01:59,330 --> 00:02:03,650
That is because whenever a user gives us command line arguments, they're always, by default treated

33
00:02:03,650 --> 00:02:06,520
as a string, even if it looks like it actually is a number.

34
00:02:07,220 --> 00:02:12,650
So we're going to make sure that whatever default value we are given or whatever value a user provides

35
00:02:12,650 --> 00:02:16,580
to us, we're always going to treat it as a string or we're going to eventually pass it into a number.

36
00:02:18,770 --> 00:02:23,630
Now, you might notice that in some places I'm using some square brackets and in others I'm using angle

37
00:02:23,630 --> 00:02:28,850
brackets, square brackets are indicating to commander that this is an optional value and it may or

38
00:02:28,940 --> 00:02:33,110
may not be present in brackets, indicate that this is a required value.

39
00:02:33,650 --> 00:02:38,480
So if a user is going to provide the support option, they must provide a number to us as well.

40
00:02:41,150 --> 00:02:42,260
All right, let's save this.

41
00:02:43,230 --> 00:02:46,040
I'm going to flip back over and we'll do another quick test at our terminal.

42
00:02:46,700 --> 00:02:48,440
Now back inside of our district.

43
00:02:49,070 --> 00:02:51,890
We should have an updated index just filed right there.

44
00:02:51,920 --> 00:02:55,460
So I should be able to run Noad Index serve.

45
00:02:56,510 --> 00:02:58,310
And still see everything work as expected.

46
00:02:58,790 --> 00:03:03,980
I should also be able to do a dash dash help and get some updated information about the different options

47
00:03:03,980 --> 00:03:04,790
we can provide.

48
00:03:05,300 --> 00:03:08,480
So now we have these different options around providing support.

49
00:03:08,780 --> 00:03:11,630
And we're also told that option that we can provide a file name as well.

50
00:03:12,750 --> 00:03:15,780
So how do we actually receive these different options and do something with them?

51
00:03:16,410 --> 00:03:20,820
Well, for that, we're going to receive them as arguments into this action function right here.

52
00:03:21,960 --> 00:03:27,540
So the first argument to this action function is going to be whatever optional arguments or required

53
00:03:27,540 --> 00:03:30,870
arguments are passed to the original route command right here.

54
00:03:31,020 --> 00:03:34,170
So in other words, the first argument is going to be our file name.

55
00:03:37,040 --> 00:03:40,910
I'm going to provide a default value for this, so this is where we can set up a default value.

56
00:03:41,240 --> 00:03:43,580
You're going to say that the user does not give us a default value.

57
00:03:43,730 --> 00:03:49,370
We're going to assume that we want to save a listing of all their cells into a notebook file.

58
00:03:50,820 --> 00:03:55,740
Then our second argument is going to be a object with all the different options inside of it.

59
00:03:56,920 --> 00:03:57,600
We will put in.

60
00:03:58,620 --> 00:04:01,290
Or how about just right now, we'll just receive, let's call it options.

61
00:04:02,310 --> 00:04:05,640
We'll take a look at what that object actually looks like and then eventually just d structure out the

62
00:04:05,640 --> 00:04:07,110
properties we actually care about.

63
00:04:08,420 --> 00:04:12,890
So then rather than doing a simple console log right here, I'm going to try to console log out filename

64
00:04:13,250 --> 00:04:14,270
and options.

65
00:04:15,210 --> 00:04:19,110
Let's then save this back to the terminal and another quick test.

66
00:04:20,339 --> 00:04:25,020
Now, I should able to do a node in index, just serve with.

67
00:04:26,360 --> 00:04:32,510
Nothing, and we'll see that my default of notebook's was provided and I got a report of four thousand

68
00:04:32,510 --> 00:04:32,900
five.

69
00:04:33,870 --> 00:04:37,680
I should be able to do a serve with books.

70
00:04:38,790 --> 00:04:46,080
And now my first argument is books, I should go to do a dash dash port of, say, 5000 and have that

71
00:04:46,080 --> 00:04:46,890
now be my port.

72
00:04:47,820 --> 00:04:50,310
I built to do a dash p.

73
00:04:51,510 --> 00:04:56,070
Yep, that's my port, and then finally, I should be able to also list options before.

74
00:04:57,380 --> 00:05:05,810
The book option as well, or really the argument if I put in Noad index dogs serve dash five thousand

75
00:05:05,990 --> 00:05:08,840
and then that filename, it should still work as expected.

76
00:05:09,060 --> 00:05:09,920
Yep, still does.

77
00:05:10,800 --> 00:05:14,990
Remember, there's going to account for users possibly thinking that they can put in options before

78
00:05:14,990 --> 00:05:15,970
the actual file name.

79
00:05:16,490 --> 00:05:21,590
The commander is incorrectly interpreting all these different variations and parsing everything accordingly.

80
00:05:22,310 --> 00:05:26,210
Finally, just one last very small variation I should be able to do.

81
00:05:26,210 --> 00:05:28,750
A dash dash port equals five thousand.

82
00:05:29,150 --> 00:05:30,580
Yep, that still works as well.

83
00:05:31,750 --> 00:05:32,820
OK, so that's pretty much it.

84
00:05:32,900 --> 00:05:35,350
You can tell that commander is really doing a lot of work here.

85
00:05:35,470 --> 00:05:40,900
It is handling just about every corner case we can possibly think of and essentially parsing all the

86
00:05:40,900 --> 00:05:44,410
different command line arguments and providing them to us as arguments.

87
00:05:45,710 --> 00:05:50,870
To our action function right here, so let's take a quick pause right here, come back the next video.

88
00:05:51,050 --> 00:05:55,220
We're going to finish up our SERP command and then move on to putting together our local API.

