1#![allow(
2 clippy::missing_errors_doc,
3 clippy::must_use_candidate,
4 clippy::missing_panics_doc
5)]
6use std::path::Path;
7
8pub(crate) use soroban_rpc as rpc;
9pub use stellar_xdr::curr as xdr;
10
11mod cli;
12pub use cli::main;
13
14pub mod assembled;
15pub mod commands;
16pub mod config;
17pub mod fee;
18pub mod get_spec;
19pub mod key;
20pub mod log;
21pub mod print;
22pub mod signer;
23pub mod toid;
24pub mod tx;
25pub mod upgrade_check;
26pub mod utils;
27pub mod wasm;
28
29pub use commands::Root;
30
31pub fn parse_cmd<T>(s: &str) -> Result<T, clap::Error>
32where
33 T: clap::CommandFactory + clap::FromArgMatches,
34{
35 let input = shlex::split(s).ok_or_else(|| {
36 clap::Error::raw(
37 clap::error::ErrorKind::InvalidValue,
38 format!("Invalid input for command:\n{s}"),
39 )
40 })?;
41 T::from_arg_matches_mut(&mut T::command().no_binary_name(true).get_matches_from(input))
42}
43
44pub trait CommandParser<T> {
45 fn parse(s: &str) -> Result<T, clap::Error>;
46
47 fn parse_arg_vec(s: &[&str]) -> Result<T, clap::Error>;
48}
49
50impl<T> CommandParser<T> for T
51where
52 T: clap::CommandFactory + clap::FromArgMatches,
53{
54 fn parse(s: &str) -> Result<T, clap::Error> {
55 parse_cmd(s)
56 }
57
58 fn parse_arg_vec(args: &[&str]) -> Result<T, clap::Error> {
59 T::from_arg_matches_mut(&mut T::command().no_binary_name(true).get_matches_from(args))
60 }
61}
62
63pub trait Pwd {
64 fn set_pwd(&mut self, pwd: &Path);
65}