Add ParseCommand error
This commit is contained in:
parent
0f12dabfc1
commit
4b5758ba51
3 changed files with 8 additions and 5 deletions
|
@ -44,7 +44,7 @@ impl ConsoleCommands {
|
|||
println!("Invalid command: {command_name}");
|
||||
self.print_commands();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
@ -81,7 +81,9 @@ impl ConsoleArgs {
|
|||
loop {
|
||||
match rl.readline(">> ") {
|
||||
Ok(line) => {
|
||||
commands.parse_and_run(line).await?
|
||||
if let Err(e) = commands.parse_and_run(line).await {
|
||||
println!("{e}");
|
||||
}
|
||||
},
|
||||
Err(x) => Err(x)?,
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ pub struct ConsoleNodeArgs {
|
|||
pub args: NodeArgs,
|
||||
}
|
||||
|
||||
impl ConsoleNodeArgs {
|
||||
impl NodeArgs {
|
||||
pub async fn run(self) -> Result<(), Error> {
|
||||
println!("{self:?}");
|
||||
Ok(())
|
||||
|
@ -31,8 +31,7 @@ impl ConsoleNodeArgs {
|
|||
}
|
||||
|
||||
pub async fn parse_and_run_console_node_command(s:Vec<String>) -> Result<(), Error> {
|
||||
let args = ConsoleNodeArgs::parse_from(s);
|
||||
args.run().await
|
||||
ConsoleNodeArgs::try_parse_from(s)?.args.run().await
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
|
|
|
@ -18,6 +18,8 @@ pub enum Error {
|
|||
Multiaddr(#[from] libp2p::multiaddr::Error),
|
||||
#[error("Noise error: {0}")]
|
||||
Noise(#[from] libp2p::noise::Error),
|
||||
#[error("Parse args error: {0}")]
|
||||
ParseCommand(#[from] clap::Error),
|
||||
#[error("Readline error: {0}")]
|
||||
Readline(#[from] rustyline::error::ReadlineError),
|
||||
#[error("Shell word split error: {0}")]
|
||||
|
|
Loading…
Add table
Reference in a new issue