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 color;
16pub mod commands;
17pub mod config;
18mod env_vars;
19pub mod get_spec;
20pub mod key;
21pub mod log;
22pub mod print;
23pub mod resources;
24pub mod signer;
25pub mod toid;
26pub mod tx;
27pub mod upgrade_check;
28pub mod utils;
29pub mod wasm;
30
31pub use commands::Root;
32
33pub fn parse_cmd<T>(s: &str) -> Result<T, clap::Error>
34where
35 T: clap::CommandFactory + clap::FromArgMatches,
36{
37 let input = shlex::split(s).ok_or_else(|| {
38 clap::Error::raw(
39 clap::error::ErrorKind::InvalidValue,
40 format!("Invalid input for command:\n{s}"),
41 )
42 })?;
43 T::from_arg_matches_mut(&mut T::command().no_binary_name(true).get_matches_from(input))
44}
45
46pub trait CommandParser<T> {
47 fn parse(s: &str) -> Result<T, clap::Error>;
48
49 fn parse_arg_vec(s: &[&str]) -> Result<T, clap::Error>;
50}
51
52impl<T> CommandParser<T> for T
53where
54 T: clap::CommandFactory + clap::FromArgMatches,
55{
56 fn parse(s: &str) -> Result<T, clap::Error> {
57 parse_cmd(s)
58 }
59
60 fn parse_arg_vec(args: &[&str]) -> Result<T, clap::Error> {
61 T::from_arg_matches_mut(&mut T::command().no_binary_name(true).get_matches_from(args))
62 }
63}
64
65pub trait Pwd {
66 fn set_pwd(&mut self, pwd: &Path);
67}