...

/

CLI Client Implementation

CLI Client Implementation

Learn how to code a CLI client that handles arguments for adding a file.

When users want to add a file, they pass the name of the file to add, its name in the destination directory, and the server address as command-line arguments. We will parse the arguments and, if certain conditions are met, call the addFile method. In this lesson, we will write the code for the addFile method in the CLI client class SampleCliClient which calls the addFile method in the FTPServiceClient class.

CLI client implementation of addFile method

If you are following along on your local machine, open the SampleCliClient class from the src/main/java/io/datajek/ftpservice/cliclient package in the ftp-service-cli-client module. The implementation of the class is discussed in the Sample CLI Client lesson. The addFile method of the SampleCliClient is responsible for adding a file to the server’s destination directory. It uses the FTPServiceClient object to initiate the add file operation, and provides callbacks for handling the results. It is defined as follows:

private void addFile(String server, String fileToAdd, String destFilename) {
logger.info("addFile method called");
}
addFile method in SampleCliClient class

It takes three parameters:

  • server: ...