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