Coverage Summary for Class: NodeCliOptions (co.rsk.config)
Class |
Method, %
|
Line, %
|
NodeCliOptions |
0%
(0/4)
|
0%
(0/8)
|
NodeCliOptions$1 |
0%
(0/2)
|
0%
(0/4)
|
NodeCliOptions$2 |
0%
(0/2)
|
0%
(0/2)
|
Total |
0%
(0/8)
|
0%
(0/14)
|
1 /*
2 * This file is part of RskJ
3 * Copyright (C) 2018 RSK Labs Ltd.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 package co.rsk.config;
19
20 import co.rsk.cli.OptionalizableCliArg;
21 import com.typesafe.config.Config;
22 import com.typesafe.config.ConfigValueFactory;
23 import org.ethereum.config.SystemProperties;
24
25 /**
26 * Options that the node can receive via command line arguments.
27 * E.g. -datadir /path/to/datadir
28 */
29 public enum NodeCliOptions implements OptionalizableCliArg {
30 RPC_CORS("rpccors", true) {
31 @Override
32 public Config withConfig(Config config, String configValue) {
33 return config
34 .withValue(SystemProperties.PROPERTY_RPC_HTTP_ENABLED, ConfigValueFactory.fromAnyRef(true))
35 .withValue(SystemProperties.PROPERTY_RPC_CORS, ConfigValueFactory.fromAnyRef(configValue));
36 }
37 },
38 BASE_PATH("base-path", true) {
39 @Override
40 public Config withConfig(Config config, String configValue) {
41 return config.withValue(SystemProperties.PROPERTY_BASE_PATH, ConfigValueFactory.fromAnyRef(configValue));
42 }
43 },
44 ;
45
46 private final String optionName;
47 private final boolean optional;
48
49 NodeCliOptions(String name, boolean optional) {
50 this.optionName = name;
51 this.optional = optional;
52 }
53
54 @Override
55 public boolean isOptional() {
56 return optional;
57 }
58
59 @Override
60 public String getName() {
61 return optionName;
62 }
63
64 /**
65 * @return a new, augmented config with settings for this flag.
66 */
67 abstract public Config withConfig(Config config, String configValue);
68 }