Skip to content

Commit

Permalink
cli: improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jul 8, 2024
1 parent 879ba6e commit 6a3e941
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,31 @@ impl RgbArgs {
&self,
stock_path: impl ToOwned<Owned = PathBuf>,
) -> Result<Stock, WalletError> {
let stock_path = stock_path.to_owned();

if self.verbose > 1 {
eprint!("Loading stock ... ");
eprint!("Loading stock from `{}` ... ", stock_path.display());
}

Stock::load(stock_path.to_owned()).map_err(WalletError::from).or_else(|err| {
let stock = Stock::load(stock_path.clone()).map_err(WalletError::from).or_else(|err| {
if matches!(err, WalletError::Deserialize(DeserializeError::Decode(DecodeError::Io(ref err))) if err.kind() == ErrorKind::NotFound) {
if self.verbose > 1 {
eprint!("stock file is absent, creating a new one ... ");
}
fs::create_dir_all(stock_path.to_owned())?;
let stock = Stock::new(stock_path.to_owned());
stock.store()?;
if self.verbose > 1 {
eprintln!("success");
}
return Ok(stock)
}
eprintln!("stock file is damaged, failing");
Err(err)
})
})?;

if self.verbose > 1 {
eprintln!("success");
}

Ok(stock)
}

pub fn rgb_stock(&self) -> Result<Stock, WalletError> {
Expand Down

0 comments on commit 6a3e941

Please sign in to comment.