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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
crate::ix!();
pub fn app_init_rpc(argv: &Vec<String>) -> i32 {
let argc = argv.len();
G_ARGS
.lock()
.setup_cli_args();
let mut error = String::default();
if !G_ARGS
.lock()
.parse_parameters(argv, &mut error)
{
eprintln!("Error parsing command line arguments: {}\n", error);
return EXIT_FAILURE;
}
let help_requested
= G_ARGS
.lock()
.help_requested();
let is_version_arg_set
= G_ARGS
.lock()
.is_arg_set("-version");
if argc < 2 || help_requested || is_version_arg_set {
let mut str_usage: String = format!{"{} RPC client version {}\n", PACKAGE_NAME, format_full_version()};
if !is_version_arg_set {
let help_message
= G_ARGS
.lock()
.get_help_message();
str_usage.push_str("\n");
str_usage += format!{"Usage: bitcoin-cli [options] <command> [params] Send command to {}\n",PACKAGE_NAME}.as_str();
str_usage += format!{"or: bitcoin-cli [options] -named <command> [name=value]... Send command to {} (with named arguments)\n",PACKAGE_NAME}.as_str();
str_usage += format!{"or: bitcoin-cli [options] help List commands\n"}.as_str();
str_usage += format!{"or: bitcoin-cli [options] help <command> Get help for a command\n"}.as_str();
str_usage += format!{"\n{}", help_message}.as_str();
}
println!{"{}", str_usage};
if argc < 2 {
eprintln!{"Error: too few parameters\n"};
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
if !check_data_dir_option() {
eprintln!{
"Error: Specified data directory \"{}\" does not exist.\n",
G_ARGS
.lock()
.get_arg("-datadir", "")
};
return EXIT_FAILURE;
}
if !G_ARGS
.lock()
.read_config_files(&mut error, Some(true)) {
eprintln!{
"Error reading configuration file: {}\n",
error
};
return EXIT_FAILURE;
}
let try_block = || -> TryBlockResult::<_,&'static str> {
select_base_params(
&G_ARGS
.lock()
.get_chain_name()
.unwrap()
);
TryBlockResult::Success
};
match try_block() {
TryBlockResult::Return(v) => return v,
TryBlockResult::Err(e) => {
eprintln!{
"Error: {}\n",
e
};
return EXIT_FAILURE;
},
TryBlockResult::Break => { }
TryBlockResult::Success => { }
}
CONTINUE_EXECUTION
}