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