Compare commits

..

26 Commits

Author SHA1 Message Date
Christoph J. Scherr 72456d5297 chore: bump version 2024-10-16 21:25:13 +02:00
Christoph J. Scherr 0617cbb11b docs: admit that this is a github project now 2024-10-16 21:22:05 +02:00
Christoph J. Scherr 44c7a110e3 chore: master and main both ok for release cd
Rust CI / cargo CI (push) Has been cancelled Details
Release-plz / Release-plz release (push) Has been cancelled Details
Release-plz / Release-plz PR (push) Has been cancelled Details
2024-10-16 20:20:11 +02:00
Christoph J. Scherr e5c5d94c22 chore: just use github actions instead of selfhosted ones, I give up :(
Rust CI / cargo CI (push) Waiting to run Details
2024-10-16 20:17:49 +02:00
Christoph J. Scherr 07f23b7e7b chore: please just fucking work dead cd pipeline
Release-plz / Release-plz release (push) Failing after 41s Details
cargo devel CI / cargo CI (push) Successful in 1m12s Details
Release-plz / Release-plz PR (push) Failing after 37s Details
2024-10-16 20:01:29 +02:00
Christoph J. Scherr f9c164b21f Merge branch 'devel'
cargo devel CI / cargo CI (push) Successful in 1m3s Details
Release-plz / Release-plz release (push) Failing after 1m22s Details
Release-plz / Release-plz PR (push) Failing after 1m29s Details
2024-10-16 19:54:49 +02:00
Christoph J. Scherr f4d7d6bc72 chore: add release action
Release-plz / Release-plz release (push) Has been cancelled Details
cargo devel CI / cargo CI (push) Has been cancelled Details
Release-plz / Release-plz PR (push) Has been cancelled Details
2024-10-16 19:54:41 +02:00
Christoph J. Scherr ee1b849c1b refactor: replace a match on a boolean with an if
cargo devel CI / cargo CI (push) Successful in 1m21s Details
2024-10-16 09:32:23 +02:00
Christoph J. Scherr b6ea9e142a chore: fix release scripts
cargo devel CI / cargo CI (push) Successful in 1m18s Details
2024-05-24 09:32:24 +02:00
Christoph J. Scherr d331c89a79 Merge pull request 'v0.2.0' (#7) from devel into master
cargo devel CI / cargo CI (push) Has been cancelled Details
Reviewed-on: #7
2024-05-24 09:31:16 +02:00
PlexSheep d51c4dde90 automatic cargo CI changes 2024-05-24 07:30:51 +00:00
Christoph J. Scherr 3d9ddac237 chore: remove doctest from CI (this is a binary)
cargo devel CI / cargo CI (push) Successful in 1m22s Details
2024-05-24 09:29:32 +02:00
Christoph J. Scherr 3cb2f2a778 chore: bump to v0.2.0
cargo devel CI / cargo CI (push) Failing after 1m13s Details
2024-05-24 09:25:25 +02:00
Christoph J. Scherr 256b362f39 fix(cli): accept "-" for stdin marker at any position #2
cargo devel CI / cargo CI (push) Has been cancelled Details
2024-05-24 09:25:08 +02:00
Christoph J. Scherr 18008e9c41 chore: add log to libpt features 2024-05-24 09:25:08 +02:00
Christoph J. Scherr 7ee73c4f64 chore: fix regression from #5, don't show time if not in meta logging mode 2024-05-24 09:25:08 +02:00
Christoph J. Scherr 7929b0af2f docs(help): dirs cannot be dumped #4 2024-05-24 09:25:08 +02:00
Christoph J. Scherr fb145a7ff4 fix!: less dependencies and simpler cli #6 2024-05-24 09:25:08 +02:00
Christoph J. Scherr f6c9c3c820 chore: update libpt and adjust to breaking changes #5
cargo devel CI / cargo CI (push) Failing after 1m21s Details
2024-05-23 14:41:35 +02:00
Christoph J. Scherr 03188c8416 Merge branch 'devel' of https://git.cscherr.de/PlexSheep/hedu into devel
cargo devel CI / cargo CI (push) Failing after 1m49s Details
2024-05-12 17:28:05 +02:00
Christoph J. Scherr 21731687f4 ci add cargo test of docs 2024-05-12 17:27:31 +02:00
PlexSheep 8091e9ce1e automatic cargo CI changes 2024-02-16 15:39:04 +00:00
Christoph J. Scherr 04f683807f
ci add clippy rustup
cargo devel CI / cargo CI (push) Successful in 4m1s Details
2024-02-16 16:35:09 +01:00
Christoph J. Scherr 138ad5d969
ci stuff
cargo devel CI / cargo CI (push) Failing after 24s Details
2024-02-16 16:11:46 +01:00
Christoph J. Scherr 9b4ef82b10
fix ci
cargo devel CI / cargo CI (push) Successful in 3m55s Details
2024-02-09 18:38:12 +01:00
Christoph J. Scherr 8ac55cb6e4
print spaces instead of tabs for higher compatability
cargo devel CI / cargo CI (push) Successful in 1m37s Details
2024-02-02 00:00:50 +01:00
9 changed files with 121 additions and 99 deletions

View File

@ -1,44 +0,0 @@
name: cargo devel CI
on:
push:
branches:
- '**'
# - '!master'
jobs:
format:
name: cargo CI
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- name: get repo
uses: actions/checkout@v4
- name: install rust
uses: dtolnay/rust-toolchain@stable
- name: install additional rust things
run: rustup component add rustfmt
- name: config custom registry
run: |
mkdir -p ~/.cargo/
echo "" > ~/.cargo/config.toml
echo "[registry]" >> ~/.cargo/config.toml
echo 'cscherr = "cscherr"' >> ~/.cargo/config.toml
echo '[registries.cscherr]' >> ~/.cargo/config.toml
echo 'index = "https://git.cscherr.de/PlexSheep/_cargo-index.git"' >> ~/.cargo/config.toml
cat ~/.cargo/config.toml
- name: cargo check
run: cargo check --all-features --all-targets
- name: cargo fix
run: cargo fix --all-features --all-targets
- name: cargo fmt
run: cargo fmt --all
- name: cargo test
run: cargo test --all-features --all-targets
- name: commit back to repository
uses: stefanzweifel/git-auto-commit-action@v5
with:
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: automatic cargo CI changes

7
.github/dependabot.yaml vendored Normal file
View File

@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
# Check for updates every Monday
schedule:
interval: "weekly"

View File

@ -1,10 +1,16 @@
name: cargo devel CI
name: Rust CI
on:
pull_request:
branches:
- '**'
push:
branches:
- '**'
# - '!master'
env:
CARGO_TERM_COLOR: always
jobs:
CI:
runs-on: ubuntu-latest
@ -19,7 +25,9 @@ jobs:
- name: install rust
uses: dtolnay/rust-toolchain@stable
- name: install additional rust things
run: rustup component add rustfmt
run: |
rustup component add rustfmt
rustup component add clippy
- name: config custom registry
run: |
mkdir -p ~/.cargo/
@ -29,17 +37,17 @@ jobs:
echo '[registries.cscherr]' >> ~/.cargo/config.toml
echo 'index = "https://git.cscherr.de/PlexSheep/_cargo-index.git"' >> ~/.cargo/config.toml
cat ~/.cargo/config.toml
- name: cargo check
run: cargo check --all-features --all-targets
- name: cargo fix
run: cargo fix --all-features --all-targets
- name: cargo clippy check
run: cargo clippy --all-features --all-targets --workspace
- name: cargo clippy fix
run: cargo clippy --fix --all-features --all-targets --workspace
- name: cargo fmt
run: cargo fmt --all
- name: cargo test
run: cargo test --all-features --all-targets
run: cargo test --all-features --all-targets --workspace
- name: commit back to repository
uses: stefanzweifel/git-auto-commit-action@v5
with:
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: automatic cargo CI changes
commit_message: "ci: automatic Rust CI changes"

54
.github/workflows/release.yaml vendored Normal file
View File

@ -0,0 +1,54 @@
name: Release-plz
permissions:
pull-requests: write
contents: write
on:
push:
branches:
- master
- main
jobs:
# Release unpublished packages.
release-plz-release:
name: Release-plz release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: MarcoIeni/release-plz-action@v0.5
with:
command: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# Create a PR with the new versions and changelog, preparing the next release.
release-plz-pr:
name: Release-plz PR
runs-on: ubuntu-latest
concurrency:
group: release-plz-${{ github.ref }}
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run release-plz
uses: MarcoIeni/release-plz-action@v0.5
with:
command: release-pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

View File

@ -1,6 +1,6 @@
[package]
name = "hedu"
version = "0.1.1"
version = "0.2.1"
edition = "2021"
publish = true
authors = ["Christoph J. Scherr <software@cscherr.de>"]
@ -12,8 +12,9 @@ repository = "https://git.cscherr.de/PlexSheep/hedu"
keywords = ["hexdumper"]
[dependencies]
libpt = { version = "0.3.11", features = ["log", "bintols"] }
libpt = { version = "0.5.1", features = [
"bintols",
"log",
], default-features = false }
clap = { version = "4.4.4", features = ["derive", "help"] }
clap-num = { version = "1.0.2" }
clap-verbosity-flag = { version = "2.0.1" }
anyhow = "1.0.79"

View File

@ -2,13 +2,14 @@
![Project badge](https://img.shields.io/badge/language-Rust-blue.svg)
![Crates.io License](https://img.shields.io/crates/l/hedu)
![Gitea Release](https://img.shields.io/gitea/v/release/PlexSheep/hedu?gitea_url=https%3A%2F%2Fgit.cscherr.de)
![Gitea language count](https://img.shields.io/gitea/languages/count/PlexSheep/hedu?gitea_url=https%3A%2F%2Fgit.cscherr.de)
[![cargo checks and tests](https://github.com/PlexSheep/hedu/actions/workflows/cargo.yaml/badge.svg)](https://github.com/PlexSheep/hedu/actions/workflows/cargo.yaml)
![GitHub Release](https://img.shields.io/github/v/release/PlexSheep/hedu)
![GitHub language count](https://img.shields.io/github/languages/count/PlexSheep/hedu)
[![Rust CI](https://github.com/PlexSheep/hedu/actions/workflows/cargo.yaml/badge.svg)](https://github.com/PlexSheep/hedu/actions/workflows/cargo.yaml)
Hex dumping tool written in Rust.
* [Original Repository](https://git.cscherr.de/PlexSheep/hedu)
* [GitHub Mirror](https://github.com/PlexSheep/hedu)
* [GitHub](https://github.com/PlexSheep/hedu)
* [crates.io](https://crates.io/crates/hedu)
* [docs.rs](https://docs.rs/crate/hedu/)

View File

@ -4,10 +4,10 @@ NEW_VERSION=$(cat Cargo.toml | rg '^\s*version\s*=\s*"([^"]*)"\s*$' -or '$1')
GIT_COMMIT_SHA=$(git rev-parse HEAD)
REPO=${PWD##*/} # name of cwd
BODY="
$(git log $(git describe --tags --abbrev=0)..HEAD --pretty="- %s" --oneline --decorate)
$(git log $(git describe --tags --abbrev=0)..HEAD --pretty="- %s" --oneline --no-decorate)
"
USER=PlexSheep
git tag "v$NEW_VERSION-test" || echo "could not tag"
git tag "v$NEW_VERSION" || echo "could not tag"
curl -X 'POST' \
'https://git.cscherr.de/api/v1/repos/PlexSheep/'$REPO'/releases' \
-H 'accept: application/json' \

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 += " ";
@ -195,7 +195,7 @@ impl Hedu {
self.sep();
self.display_buf += &format!(
"{:08X} {LINE_SEP_VERT} read total:\t\t {:<8} {:<15}",
"{:08X} {LINE_SEP_VERT} read total: {:<8} {:<15}",
self.rd_counter,
humanbytes(self.rd_counter),
format!("({} B)", self.rd_counter)
@ -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,12 @@
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(
@ -29,10 +28,9 @@ Author: {author-with-newline}
)]
/// Hexdumper written in Rust
pub struct Cli {
// clap_verbosity_flag seems to make this a global option implicitly
/// set a verbosity, multiple allowed (f.e. -vvv)
#[command(flatten)]
pub verbose: Verbosity<InfoLevel>,
/// show more details
#[arg(short, long)]
pub verbose: bool,
/// show additional logging meta data
#[arg(long)]
@ -57,17 +55,22 @@ pub struct Cli {
/// a data source, probably a file.
///
/// If left empty or set as "-", the program will read from stdin.
///
/// Directories cannot be dumped.
pub data_source: Vec<String>,
}
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.contains(&"-".to_string()) {
for data_source in &cli.data_source {
let data_source: PathBuf = PathBuf::from(data_source);
if data_source.is_dir() {
warn!("Not a file {:?}, skipping", data_source);
warn!(
"'{:?}' is a directory and cannot be dumped, skipping",
data_source
);
// std::process::exit(1);
continue;
}
@ -89,23 +92,20 @@ 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() {
let mut config = Hedu::new(cli.chars, cli.skip, cli.show_identical, cli.limit);
// FIXME: find a better way to get the file name
// Currently, skipped sources make an extra newline here.
match config.chars {
false => {
println!("{:─^59}", format!(" {} ", cli.data_source[i]));
}
true => {
println!("{:─^80}", format!(" {} ", cli.data_source[i]));
}
if config.chars {
println!("{:─^80}", format!(" {} ", cli.data_source[i]));
} else {
println!("{:─^59}", format!(" {} ", cli.data_source[i]));
}
match config.dump(&mut **source) {
Ok(_) => (),
Ok(()) => (),
Err(err) => {
error!("Could not dump data of file: {err}");
std::process::exit(3);
@ -119,21 +119,16 @@ fn main() {
fn cli_parse() -> Cli {
let cli = Cli::parse();
let ll: Level = match cli.verbose.log_level().unwrap().as_str() {
"TRACE" => Level::TRACE,
"DEBUG" => Level::DEBUG,
"INFO" => Level::INFO,
"WARN" => Level::WARN,
"ERROR" => Level::ERROR,
_ => {
unreachable!();
}
let ll: Level = if cli.verbose {
Level::INFO
} else {
Level::DEBUG
};
if cli.meta {
Logger::init(None, Some(ll), false).expect("could not initialize Logger");
let _ = Logger::builder().max_level(ll).build();
} else {
// less verbose version
Logger::init_mini(Some(ll)).expect("could not initialize Logger");
let _ = Logger::builder().show_time(false).build();
}
return cli;
cli
}