Skip to content
Snippets Groups Projects
Commit 51f7f699 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

color error in red and fix identity get with no indexer

parent 51ba001a
No related branches found
No related tags found
No related merge requests found
...@@ -1061,6 +1061,16 @@ version = "1.0.2" ...@@ -1061,6 +1061,16 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
[[package]]
name = "colored"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
dependencies = [
"lazy_static",
"windows-sys 0.48.0",
]
[[package]] [[package]]
name = "combine" name = "combine"
version = "3.8.1" version = "3.8.1"
...@@ -2123,6 +2133,7 @@ dependencies = [ ...@@ -2123,6 +2133,7 @@ dependencies = [
"bip39", "bip39",
"bs58", "bs58",
"clap", "clap",
"colored",
"comfy-table", "comfy-table",
"confy", "confy",
"directories 5.0.1", "directories 5.0.1",
......
...@@ -52,6 +52,7 @@ nacl = { version = "^0.5.3" } # for old-style key gen ...@@ -52,6 +52,7 @@ nacl = { version = "^0.5.3" } # for old-style key gen
# this is beta crate for password-encrypted files # this is beta crate for password-encrypted files
age = { default-features = false, version = "^0.10.0", features = ["armor"] } age = { default-features = false, version = "^0.10.0", features = ["armor"] }
bip39 = { version = "^2.0.0", features = ["rand"] } # mnemonic bip39 = { version = "^2.0.0", features = ["rand"] } # mnemonic
colored = "2.1.0"
# allows to build gcli for different runtimes and with different predefined networks # allows to build gcli for different runtimes and with different predefined networks
[features] [features]
......
...@@ -338,9 +338,25 @@ pub async fn get_identity( ...@@ -338,9 +338,25 @@ pub async fn get_identity(
.map(|i| i.issuer.unwrap().identity.unwrap().name.to_string()) .map(|i| i.issuer.unwrap().identity.unwrap().name.to_string())
.collect(), .collect(),
})), })),
_ => Err(GcliError::Indexer( (Some(s), None) => match indexer {
"Duniter and Indexer do not agree if x is smith".to_string(), Some(_) => Err(GcliError::Indexer(format!(
)), "Duniter and Indexer do not agree if {index} is smith"
))),
None => Ok(Some(SmithView {
status: s.status,
cert_issued_count: s.issued_certs.len(),
cert_issued: s.issued_certs.into_iter().map(|e| e.to_string()).collect(),
cert_received_count: s.received_certs.len(),
cert_received: s
.received_certs
.into_iter()
.map(|e| e.to_string())
.collect(),
})),
},
(None, Some(_)) => Err(GcliError::Indexer(format!(
"Duniter and Indexer do not agree if {pseudo} is smith"
))),
}?; }?;
// build view // build view
......
...@@ -11,6 +11,7 @@ use anyhow::anyhow; ...@@ -11,6 +11,7 @@ use anyhow::anyhow;
use clap::builder::OsStr; use clap::builder::OsStr;
use clap::Parser; use clap::Parser;
use codec::Encode; use codec::Encode;
use colored::Colorize;
use data::*; use data::*;
use display::DisplayEvent; use display::DisplayEvent;
use keys::*; use keys::*;
...@@ -187,7 +188,7 @@ async fn main() -> Result<(), GcliError> { ...@@ -187,7 +188,7 @@ async fn main() -> Result<(), GcliError> {
Subcommand::Publish => commands::publish::handle_command().await, Subcommand::Publish => commands::publish::handle_command().await,
}; };
if let Err(ref e) = result { if let Err(ref e) = result {
println!("{}", e) println!("{}", e.to_string().red())
} }
// still return result for detailed error message // still return result for detailed error message
// println!(); // println!();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment