1 /*
2 * Copyright 2015 Data Archiving and Networked Services (an institute of
3 * Koninklijke Nederlandse Akademie van Wetenschappen), King's College London,
4 * Georg-August-Universitaet Goettingen Stiftung Oeffentlichen Rechts
5 *
6 * Licensed under the EUPL, Version 1.1 or – as soon they will be approved by
7 * the European Commission - subsequent versions of the EUPL (the "Licence");
8 * You may not use this work except in compliance with the Licence.
9 * You may obtain a copy of the Licence at:
10 *
11 * https://joinup.ec.europa.eu/software/page/eupl
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the Licence is distributed on an "AS IS" basis,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the Licence for the specific language governing
17 * permissions and limitations under the Licence.
18 */
19
20 package eu.ehri.project.commands;
21
22 import com.tinkerpop.frames.FramedGraph;
23 import org.apache.commons.cli.CommandLine;
24
25 /**
26 * Command-line tools to perform actions on the graph database need
27 * to specify a help text about the functionality of the tool and
28 * a string to explain their usage.
29 */
30 public interface Command {
31 /**
32 * Get information about the functionality of the command.
33 *
34 * @return a help text
35 */
36 String getHelp();
37
38 /**
39 * Get a short hint about the usage of the command.
40 *
41 * @return a usage text
42 */
43 String getUsage();
44
45 /**
46 * Get the formatted help blurb, including options.
47 *
48 * @return a help string.
49 */
50 String getDetailedHelp();
51
52 /**
53 * Get footer text for the help.
54 *
55 * @return a text string
56 */
57 default String getHelpFooter() {
58 return "";
59 }
60
61 /**
62 * Execute this command with the given command line options.
63 *
64 * @param graph the graph database
65 * @param cmdLine the command line options
66 * @return a status code (0 = success)
67 */
68 int execWithOptions(FramedGraph<?> graph, CommandLine cmdLine) throws Exception;
69
70 /**
71 * Execute this command with the given arguments.
72 *
73 * @param graph the graph database
74 * @param args the raw argument strings
75 * @return a status code (0 = success)
76 */
77 int exec(FramedGraph<?> graph, String[] args) throws Exception;
78 }