-
Notifications
You must be signed in to change notification settings - Fork 266
/
NodeCliOptions.java
68 lines (61 loc) · 2.22 KB
/
NodeCliOptions.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
/*
* This file is part of RskJ
* Copyright (C) 2018 RSK Labs Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package co.rsk.config;
import co.rsk.cli.OptionalizableCliArg;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigValueFactory;
import org.ethereum.config.SystemProperties;
/**
* Options that the node can receive via command line arguments.
* E.g. -datadir /path/to/datadir
*/
public enum NodeCliOptions implements OptionalizableCliArg {
RPC_CORS("rpccors", true) {
@Override
public Config withConfig(Config config, String configValue) {
return config
.withValue(SystemProperties.PROPERTY_RPC_HTTP_ENABLED, ConfigValueFactory.fromAnyRef(true))
.withValue(SystemProperties.PROPERTY_RPC_CORS, ConfigValueFactory.fromAnyRef(configValue));
}
},
BASE_PATH("base-path", true) {
@Override
public Config withConfig(Config config, String configValue) {
return config.withValue(SystemProperties.PROPERTY_BASE_PATH, ConfigValueFactory.fromAnyRef(configValue));
}
},
;
private final String optionName;
private final boolean optional;
NodeCliOptions(String name, boolean optional) {
this.optionName = name;
this.optional = optional;
}
@Override
public boolean isOptional() {
return optional;
}
@Override
public String getName() {
return optionName;
}
/**
* @return a new, augmented config with settings for this flag.
*/
abstract public Config withConfig(Config config, String configValue);
}