1use {
2 crate::{
3 address_lookup_table::AddressLookupTableSubCommands, cli::*, cluster_query::*, feature::*,
4 inflation::*, nonce::*, program::*, program_v4::ProgramV4SubCommands, stake::*,
5 validator_info::*, vote::*, wallet::*,
6 },
7 clap::{App, AppSettings, Arg, ArgGroup, SubCommand},
8 solana_clap_utils::{self, hidden_unless_forced, input_validators::*, keypair::*},
9 solana_cli_config::CONFIG_FILE,
10};
11
12pub fn get_clap_app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, 'v> {
13 App::new(name)
14 .about(about)
15 .version(version)
16 .setting(AppSettings::SubcommandRequiredElseHelp)
17 .arg(
18 Arg::with_name("skip_preflight")
19 .long("skip-preflight")
20 .global(true)
21 .takes_value(false)
22 .help("Skip the preflight check when sending transactions"),
23 )
24 .arg({
25 let arg = Arg::with_name("config_file")
26 .short("C")
27 .long("config")
28 .value_name("FILEPATH")
29 .takes_value(true)
30 .global(true)
31 .help("Configuration file to use");
32 if let Some(ref config_file) = *CONFIG_FILE {
33 arg.default_value(config_file)
34 } else {
35 arg
36 }
37 })
38 .arg(
39 Arg::with_name("json_rpc_url")
40 .short("u")
41 .long("url")
42 .value_name("URL_OR_MONIKER")
43 .takes_value(true)
44 .global(true)
45 .validator(is_url_or_moniker)
46 .help(
47 "URL for Solana's JSON RPC or moniker (or their first letter): \
48 [mainnet-beta, testnet, devnet, localhost]",
49 ),
50 )
51 .arg(
52 Arg::with_name("websocket_url")
53 .long("ws")
54 .value_name("URL")
55 .takes_value(true)
56 .global(true)
57 .validator(is_url)
58 .help("WebSocket URL for the solana cluster"),
59 )
60 .arg(
61 Arg::with_name("keypair")
62 .short("k")
63 .long("keypair")
64 .value_name("KEYPAIR")
65 .global(true)
66 .takes_value(true)
67 .help("Filepath or URL to a keypair"),
68 )
69 .arg(
70 Arg::with_name("commitment")
71 .long("commitment")
72 .takes_value(true)
73 .possible_values(&[
74 "processed",
75 "confirmed",
76 "finalized",
77 "recent", "single", "singleGossip", "root", "max", ])
83 .value_name("COMMITMENT_LEVEL")
84 .hide_possible_values(true)
85 .global(true)
86 .help(
87 "Return information at the selected commitment level \
88 [possible values: processed, confirmed, finalized]",
89 ),
90 )
91 .arg(
92 Arg::with_name("verbose")
93 .long("verbose")
94 .short("v")
95 .global(true)
96 .help("Show additional information"),
97 )
98 .arg(
99 Arg::with_name("use_quic")
100 .long("use-quic")
101 .global(true)
102 .help("Use QUIC when sending transactions."),
103 )
104 .arg(
105 Arg::with_name("use_udp")
106 .long("use-udp")
107 .global(true)
108 .conflicts_with("use_quic")
109 .help("Use UDP when sending transactions."),
110 )
111 .arg(
112 Arg::with_name("use_tpu_client")
113 .long("use-tpu-client")
114 .global(true)
115 .help("Use TPU client when sending transactions."),
116 )
117 .arg(
118 Arg::with_name("no_address_labels")
119 .long("no-address-labels")
120 .global(true)
121 .help("Do not use address labels in the output"),
122 )
123 .arg(
124 Arg::with_name("output_format")
125 .long("output")
126 .value_name("FORMAT")
127 .global(true)
128 .takes_value(true)
129 .possible_values(&["json", "json-compact"])
130 .help("Return information in specified output format"),
131 )
132 .arg(
133 Arg::with_name(SKIP_SEED_PHRASE_VALIDATION_ARG.name)
134 .long(SKIP_SEED_PHRASE_VALIDATION_ARG.long)
135 .global(true)
136 .help(SKIP_SEED_PHRASE_VALIDATION_ARG.help),
137 )
138 .arg(
139 Arg::with_name("rpc_timeout")
140 .long("rpc-timeout")
141 .value_name("SECONDS")
142 .takes_value(true)
143 .default_value(DEFAULT_RPC_TIMEOUT_SECONDS)
144 .global(true)
145 .hidden(hidden_unless_forced())
146 .help("Timeout value for RPC requests"),
147 )
148 .arg(
149 Arg::with_name("confirm_transaction_initial_timeout")
150 .long("confirm-timeout")
151 .value_name("SECONDS")
152 .takes_value(true)
153 .default_value(DEFAULT_CONFIRM_TX_TIMEOUT_SECONDS)
154 .global(true)
155 .hidden(hidden_unless_forced())
156 .help("Timeout value for initial transaction status"),
157 )
158 .cluster_query_subcommands()
159 .feature_subcommands()
160 .inflation_subcommands()
161 .nonce_subcommands()
162 .program_subcommands()
163 .program_v4_subcommands()
164 .address_lookup_table_subcommands()
165 .stake_subcommands()
166 .validator_info_subcommands()
167 .vote_subcommands()
168 .wallet_subcommands()
169 .subcommand(
170 SubCommand::with_name("config")
171 .about("Solana command-line tool configuration settings")
172 .aliases(&["get", "set"])
173 .setting(AppSettings::SubcommandRequiredElseHelp)
174 .subcommand(
175 SubCommand::with_name("get")
176 .about("Get current config settings")
177 .arg(
178 Arg::with_name("specific_setting")
179 .index(1)
180 .value_name("CONFIG_FIELD")
181 .takes_value(true)
182 .possible_values(&[
183 "json_rpc_url",
184 "websocket_url",
185 "keypair",
186 "commitment",
187 ])
188 .help("Return a specific config setting"),
189 ),
190 )
191 .subcommand(
192 SubCommand::with_name("set")
193 .about("Set a config setting")
194 .group(
195 ArgGroup::with_name("config_settings")
196 .args(&["json_rpc_url", "websocket_url", "keypair", "commitment"])
197 .multiple(true)
198 .required(true),
199 ),
200 )
201 .subcommand(
202 SubCommand::with_name("import-address-labels")
203 .about("Import a list of address labels")
204 .arg(
205 Arg::with_name("filename")
206 .index(1)
207 .value_name("FILENAME")
208 .takes_value(true)
209 .help("YAML file of address labels"),
210 ),
211 )
212 .subcommand(
213 SubCommand::with_name("export-address-labels")
214 .about("Export the current address labels")
215 .arg(
216 Arg::with_name("filename")
217 .index(1)
218 .value_name("FILENAME")
219 .takes_value(true)
220 .help("YAML file to receive the current address labels"),
221 ),
222 ),
223 )
224 .subcommand(
225 SubCommand::with_name("completion")
226 .about("Generate completion scripts for various shells")
227 .arg(
228 Arg::with_name("shell")
229 .long("shell")
230 .short("s")
231 .takes_value(true)
232 .possible_values(&["bash", "fish", "zsh", "powershell", "elvish"])
233 .default_value("bash"),
234 ),
235 )
236}