forked from tronprotocol/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDb.java
More file actions
47 lines (41 loc) · 1.41 KB
/
Db.java
File metadata and controls
47 lines (41 loc) · 1.41 KB
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
package org.tron.plugins;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import picocli.CommandLine;
@CommandLine.Command(name = "db",
mixinStandardHelpOptions = true,
version = "db command 1.0",
description = "An rich command set that provides high-level operations for dbs.",
subcommands = {CommandLine.HelpCommand.class, DbMove.class, DbArchive.class},
commandListHeading = "%nCommands:%n%nThe most commonly used git commands are:%n"
)
public class Db {
static class ConfigConverter implements CommandLine.ITypeConverter<Config> {
ConfigConverter() {
}
public Config convert(String value) throws IOException {
File file = Paths.get(value).toFile();
if (file.exists() && file.isFile()) {
return ConfigFactory.parseFile(Paths.get(value).toFile());
} else {
throw new IOException("DB config [" + value + "] not exist!");
}
}
}
static class PathConverter implements CommandLine.ITypeConverter<Path> {
PathConverter() {
}
public Path convert(String value) throws IOException {
File file = Paths.get(value).toFile();
if (file.exists() && file.isDirectory()) {
return file.toPath();
} else {
throw new IOException("DB path [" + value + "] not exist!");
}
}
}
}