Difference between revisions of "Home Library CLI"
(→Create a directory) |
(→Create a directory) |
||
Line 86: | Line 86: | ||
* '''path''': the path where the directory will be created. | * '''path''': the path where the directory will be created. | ||
* '''description''': the description of the new folder. | * '''description''': the description of the new folder. | ||
− | |||
=== Example === | === Example === |
Revision as of 16:18, 24 March 2016
Introduction
The Home Library CLI is a Java library providing command line interface to Home Library WebApp.
This CLI library has following features:
- Create Folder: to create a folder in the root or in a subfolder.
- List Folder: to list the content of a specific folder.
- Upload a file: to upload a file in given folder.
- Remove files and folders: to remove a file or a folder (including subforders).
- Test: a simple test to check the correct behavior of the features above.
The following sections will discuss each of these commands in turn, and discuss how to use them with Home Library CLI.
Usage
Prerequisites
Home Library CLI is a jar-with-depencencies, you only need a Java 7 JDK. Download the latest release from the here or by clicking this link: xxx
Start
After downloading the Home Library CLI jar just start it as follows:
java -jar home-library-cli-<$version>-SNAPSHOT-jar-with-dependencies.jar
NOTE: Replace <$version> with the current version.
This starts the library and writes some help lines:
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar Usage: java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar <command> Where <command> is: mkdir ls rm put test
Run the Test
To check the correct behavior of all the features:
java -jar home-library-cli-<$version>-SNAPSHOT-jar-with-dependencies.jar test
Example:
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar test param N.0: test List Folder / Response Code : 200 0 elements found Create Folder myFolder-7cf437b6-e21f-4f87-a4a3-73f0b2a515c2 Response Code : 200 myFolder-7cf437b6-e21f-4f87-a4a3-73f0b2a515c2 created in / Save images in myFolder-7cf437b6-e21f-4f87-a4a3-73f0b2a515c2 List Folder / Response Code : 200 0 elements found Response Code : 200 myFolder-7cf437b6-e21f-4f87-a4a3-73f0b2a515c2 deleted. HL CLI test successfully completed.
Create a directory
To create a directory, if it does not already exist.
java -jar home-library-cli-<$version>-SNAPSHOT-jar-with-dependencies.jar mkdir name [path] [description]
Mandatory arguments:
- name: the name of the new folder.
Optional arguments:
- path: the path where the directory will be created.
- description: the description of the new folder.
Example
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar mkdir myFolder param N.0: mkdir param N.1: myFolder Create Folder myFolder Response Code : 200 myFolder has been created.
Save a file
java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar put /home/user/Downloads/image.jpg myFolder
Output example:
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar put /home/user/Downloads/image.jpg myFolder param N.0: put param N.1: /home/user/Downloads/image.jpg param N.2: myFolder /myFolder/image.jpg has been saved.
List a Folder
java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar ls myFolder
Output example:
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar ls myFolder param N.0: ls param N.1: myFolder Response Code : 200 1 items found. myFolder/image.jpg
Remove files or directories
To remove files or directories:
java -jar home-library-cli-<$version>-SNAPSHOT-jar-with-dependencies.jar rm fileOrDirectory
Remove a file
Example:
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar rm myFolder/image.jpg param N.0: rm param N.1: myFolder/image.jpg Response Code : 200 /myFolder/image.jpg deleted.
Remove a directory
Example:
user@my-pc:~$ java -jar home-library-cli-1.0.0-SNAPSHOT-jar-with-dependencies.jar rm myFolder param N.0: rm param N.1: myFolder Response Code : 200 myFolder deleted.