Merge branch 'devel' of https://git.cscherr.de/PlexSheep/hedu into devel
cargo devel CI / cargo CI (push) Failing after 1m49s Details

This commit is contained in:
Christoph J. Scherr 2024-05-12 17:28:05 +02:00
commit 03188c8416
2 changed files with 11 additions and 11 deletions

View File

@ -9,7 +9,7 @@ use libpt::log::{debug, error, trace, warn};
pub const BYTES_PER_LINE: usize = 16;
pub const LINE_SEP_HORIZ: char = '─';
pub const LINE_SEP_VERT: char = '│';
pub const CHAR_BORDER: &'static str = "|";
pub const CHAR_BORDER: &str = "|";
pub trait DataSource: Read {
fn skip(&mut self, length: usize) -> std::io::Result<()>;
@ -93,16 +93,16 @@ impl Hedu {
self.display_buf += &format!("{:08X} {LINE_SEP_VERT} ", self.data_idx);
if self.len != 0 {
for i in 0..self.len {
if i as usize % BYTES_PER_LINE == BYTES_PER_LINE / 2 {
if i % BYTES_PER_LINE == BYTES_PER_LINE / 2 {
self.display_buf += " ";
}
self.display_buf += &format!("{:02X} ", self.buf[self.alt_buf][i]);
}
if self.len == BYTES_PER_LINE / 2 {
self.display_buf += " "
self.display_buf += " ";
}
for i in 0..(BYTES_PER_LINE - self.len) {
if i as usize % BYTES_PER_LINE == BYTES_PER_LINE / 2 {
if i % BYTES_PER_LINE == BYTES_PER_LINE / 2 {
self.display_buf += " ";
}
self.display_buf += " ";
@ -237,7 +237,7 @@ impl Hedu {
/// interpret characters for the --chars option
fn mask_chars(c: char) -> char {
if c.is_ascii_graphic() {
return c;
c
} else if c == '\n' {
return '↩';
} else if c == ' ' {

View File

@ -5,13 +5,13 @@
use std::{fs::File, io::IsTerminal, path::PathBuf};
use libpt::log::*;
use libpt::log::{error, trace, warn, Level, Logger};
use clap::Parser;
use clap_verbosity_flag::{InfoLevel, Verbosity};
mod dumper;
use dumper::*;
use dumper::{DataSource, Hedu};
#[derive(Debug, Clone, Parser)]
#[command(
@ -63,7 +63,7 @@ pub struct Cli {
fn main() {
let mut cli = cli_parse();
let mut sources: Vec<Box<dyn DataSource>> = Vec::new();
if cli.data_source.len() > 0 && cli.data_source[0] != "-" {
if !cli.data_source.is_empty() && cli.data_source[0] != "-" {
for data_source in &cli.data_source {
let data_source: PathBuf = PathBuf::from(data_source);
if data_source.is_dir() {
@ -89,7 +89,7 @@ fn main() {
}
// just for the little header
cli.data_source = Vec::new();
cli.data_source.push(format!("stdin"));
cli.data_source.push("stdin".to_string());
sources.push(Box::new(stdin));
}
for (i, source) in sources.iter_mut().enumerate() {
@ -105,7 +105,7 @@ fn main() {
}
}
match config.dump(&mut **source) {
Ok(_) => (),
Ok(()) => (),
Err(err) => {
error!("Could not dump data of file: {err}");
std::process::exit(3);
@ -135,5 +135,5 @@ fn cli_parse() -> Cli {
// less verbose version
Logger::init_mini(Some(ll)).expect("could not initialize Logger");
}
return cli;
cli
}