-
-
Notifications
You must be signed in to change notification settings - Fork 267
/
Commands.java
73 lines (67 loc) · 2.3 KB
/
Commands.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package org.basex.core;
import static org.basex.core.Text.*;
/**
* This class defines the available command-line commands.
*
* @author BaseX Team 2005-12, BSD License
* @author Christian Gruen
*/
@SuppressWarnings("all")
public interface Commands {
/** Create commands. */
enum CmdCreate { DATABASE, DB, INDEX, USER, BACKUP, EVENT }
/** Info commands. */
enum CmdInfo { NULL, DATABASE, DB, INDEX, STORAGE }
/** Drop commands. */
enum CmdDrop { DATABASE, DB, INDEX, USER, BACKUP, EVENT }
/** Optimize commands. */
enum CmdOptimize { NULL, ALL }
/** Show commands. */
enum CmdShow { DATABASES, SESSIONS, USERS, BACKUPS, EVENTS }
/** Permission commands. */
enum CmdPerm { NONE, READ, WRITE, CREATE, ADMIN }
/** Index types. */
enum CmdIndex { TEXT, ATTRIBUTE, FULLTEXT }
/** Index types. */
enum CmdIndexInfo { NULL, TEXT, ATTRIBUTE, FULLTEXT, PATH, TAG, ATTNAME }
/** Alter types. */
enum CmdAlter { DATABASE, DB, USER }
/** Repo types. */
enum CmdRepo { INSTALL, DELETE, LIST }
/** Command definitions. */
enum Cmd {
ADD(HELPADD), ALTER(HELPALTER), CHECK(HELPCHECK), CLOSE(HELPCLOSE),
COPY(HELPCOPY), CREATE(HELPCREATE), CS(HELPCS), DELETE(HELPDELETE),
DROP(HELPDROP), EXIT(HELPEXIT), EXPORT(HELPEXPORT), FIND(HELPFIND),
FLUSH(HELPFLUSH), GET(HELPGET), GRANT(HELPGRANT), HELP(HELPHELP),
INFO(HELPINFO), KILL(HELPKILL), LIST(HELPLIST), OPEN(HELPOPEN),
OPTIMIZE(HELPOPTIMIZE), PASSWORD(HELPPASSWORD), RENAME(HELPRENAME),
REPLACE(HELPREPLACE), REPO(HELPREPO), RESTORE(HELPRESTORE),
RETRIEVE(HELPRETRIEVE), RUN(HELPRUN), SET(HELPSET),
SHOW(HELPSHOW), STORE(HELPSTORE), XQUERY(HELPXQUERY);
/** Help texts. */
private final String[] help;
/**
* Default constructor.
* @param h help texts, or {@code null} if command is hidden.
*/
Cmd(final String... h) {
help = h;
}
/**
* Returns a help string.
* @param detail show details
* @return string
*/
public final String help(final boolean detail) {
final StringBuilder sb = new StringBuilder();
if(help == null) {
if(detail) sb.append(NOHELP).append(NL);
} else {
sb.append(this + " " + help[0] + NL + " " + help[1] + NL);
if(detail) sb.append(NL + help[2] + NL);
}
return sb.toString();
}
}
}