All right.
So welcome back everyone.
So in our previous lecture we saw how to run command on the system in this lecture.
We are going to refactor our code to make it look more clean and nice.
So we will create a function that will take in the command.
And then it will turn out to print out the results so I'm going to create a new function here.
So let's call this function execute.
Come on.
And in our previous case we saw that our function was only able to take one input.
So which is that date.
And if we want to give him actually better command line arguments we've got a lot able to provide these
arguments to this function so here we are going to develop a functionality so that we can handle command
line arguments as well.
So the first item and this function will receive would be the command of the actual command for example
to date or unless as we saw in previous lectures and this would be of type String and then we would
like to provide any number of arguments in a string list or string theory.
So we can create a good argument.
And it would be of type String list
and then this function is going to be done and add it.
So the first thing we would want to do is we would set this argument at 8:00 when you ready it will
go on arguments of ideas and then we will call this function which is you dot com on.
So I'm just going to copy everything from here.
So just copied and pasted here.
And then what we like to do is to provide this argument inside this function because if you check documentation
you can see that it can take any number of foreign elements.
So we can provide the same variable this variable here.
So I'm going to call this as G.S. and then will write three dots or we imply that we are taking any
number of arguments since we are already returning this error from here so we don't have to initialize
it here again.
So we can remove this column from here and then if there is an error we can simply print the so we can
save it.
Otherwise if everything works perfectly we can simply return nil from here.
So now we have a function that takes in any command line argument and then returns out.
So the results on the screen and here what we can do is you can call this function.
So you can see execute command and then we will provide the command and then let's say if we want to
avoid another argument let's say you want to run this command which is a less minus and and Richard
list in detail.
So we were like list here and then we would provide the arguments investing moment.
So into a string.
And the second argument would be minus.
So if we run this code now we can say go run mean that go.
And now you can see that it lists out the on the details about this file for example when this file
was created which operating system is it what's the permission.
And also the number of quite acceptable.
So that's how you can defect in your code.
So this is an example.
And you can follow this example in next lectures to do factor your code accordingly.
So I'm going to stop here and in next lecture we'll proceed for the.