From df2c07573d68da6dbbde81fca703ed2fae122741 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Wed, 17 Jan 2024 13:57:47 +0100 Subject: [PATCH 1/5] better deps and move things --- Cargo.toml | 44 ++++++++++--------- members/libpt-bin/Cargo.toml | 41 ----------------- members/libpt-bintols/Cargo.toml | 6 ++- .../lib.rs => libpt-bintols/src/hedu/mod.rs} | 0 members/libpt-ccc/Cargo.toml | 22 ---------- members/libpt-core/Cargo.toml | 2 +- members/libpt-hedu/Cargo.toml | 21 --------- members/libpt-math/Cargo.toml | 4 ++ .../src/lib.rs => libpt-math/src/ccc/mod.rs} | 0 members/libpt-net/Cargo.toml | 6 +-- {members/libpt-bin/src => src}/ccc/mod.rs | 0 {members/libpt-bin/src => src}/hedu/mod.rs | 0 {members/libpt-bin/src => src}/main/args.rs | 0 {members/libpt-bin/src => src}/main/mod.rs | 0 14 files changed, 35 insertions(+), 111 deletions(-) delete mode 100644 members/libpt-bin/Cargo.toml rename members/{libpt-hedu/src/lib.rs => libpt-bintols/src/hedu/mod.rs} (100%) delete mode 100644 members/libpt-ccc/Cargo.toml delete mode 100644 members/libpt-hedu/Cargo.toml rename members/{libpt-ccc/src/lib.rs => libpt-math/src/ccc/mod.rs} (100%) rename {members/libpt-bin/src => src}/ccc/mod.rs (100%) rename {members/libpt-bin/src => src}/hedu/mod.rs (100%) rename {members/libpt-bin/src => src}/main/args.rs (100%) rename {members/libpt-bin/src => src}/main/mod.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 14b4bff..8fe001d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,14 +3,11 @@ resolver = "2" members = [ ".", "members/libpt-core", - "members/libpt-bintols", "members/libpt-math", - "members/libpt-bin", "members/libpt-log", "members/libpt-net", - "members/libpt-hedu", ] -default-members = [".", "members/libpt-bin", "members/libpt-core"] +default-members = [".", "members/libpt-core"] [workspace.package] publish = true version = "0.2.0-alpha.3" @@ -31,8 +28,13 @@ categories = [ [workspace.dependencies] anyhow = "1.0.79" thiserror = "1.0.56" -libpt-log = { version = "0.2.0-alpha.2", path = "../libpt-log" } -libpt-bintols = { version = "0.2.0-alpha.2", ath = "../libpt-bintols" } +libpt-core = { version = "0.2.0-alpha.2", path = "members/libpt-core", registry = "cscherr" } +libpt-bintols = { version = "0.2.0-alpha.2", path = "members/libpt-bintols", registry = "cscherr", optional = true } +libpt-hedu = { version = "0.2.0-alpha.2", path = "members/libpt-hedu", registry = "cscherr", optional = true } +libpt-log = { version = "0.2.0-alpha.2", path = "members/libpt-log", registry = "cscherr", optional = true } +libpt-math = { version = "0.2.0-alpha.2", path = "members/libpt-math", registry = "cscherr", optional = true } +libpt-ccc = { version = "0.2.0-alpha.2", path = "members/libpt-ccc", registry = "cscherr", optional = true } +libpt-net = { version = "0.2.0-alpha.2", path = "members/libpt-net", registry = "cscherr", optional = true } [package] name = "libpt" @@ -52,13 +54,12 @@ categories.workspace = true default = ["log", "core"] all = ["default", "math", "log", "bintols", "net", "ccc", "hedu", "core"] core = [] -fw = [] -math = [] -log = [] -bintols = [] -net = [] +math = ["dep:libpt-math"] +log = ["dep:libpt-log"] +bintols = ["dep:libpt-bintols"] +net = ["dep:libpt-net"] ccc = ["math"] -hedu = ["bintols"] +bin = ["bintols", "math", "dep:clap", "dep:clap-num", "dep:clap-verbosity-flag"] [lib] name = "libpt" @@ -68,13 +69,14 @@ crate-type = [ "rlib", ] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] -libpt-bintols = { version = "0.2.0-alpha.2", path = "members/libpt-bintols", registry="cscherr"} -libpt-core = { version = "0.2.0-alpha.2", path = "members/libpt-core", registry="cscherr" } -libpt-hedu = { version = "0.2.0-alpha.2", path = "members/libpt-hedu", registry="cscherr" } -libpt-log = { version = "0.2.0-alpha.2", path = "members/libpt-log", registry="cscherr" } -libpt-math = { version = "0.2.0-alpha.2", path = "members/libpt-math", registry="cscherr" } -libpt-ccc = { version = "0.2.0-alpha.2", path = "members/libpt-ccc", registry="cscherr" } -libpt-net = { version = "0.2.0-alpha.2", path = "members/libpt-net", registry="cscherr" } +libpt-core = { workspace = true } +libpt-bintols = { workspace = true } +libpt-hedu = { workspace = true } +libpt-log = { workspace = true } +libpt-math = { workspace = true } +libpt-ccc = { workspace = true } +libpt-net = { workspace = true } +clap = { version = "4.4.4", features = ["derive"], optional = true } +clap-num = { version = "1.0.2", optional = true } +clap-verbosity-flag = { version = "2.0.1", optional = true } diff --git a/members/libpt-bin/Cargo.toml b/members/libpt-bin/Cargo.toml deleted file mode 100644 index a0cd981..0000000 --- a/members/libpt-bin/Cargo.toml +++ /dev/null @@ -1,41 +0,0 @@ -[package] -autobins = true -name = "libpt-bin" -publish.workspace = true -version.workspace = true -edition.workspace = true -authors.workspace = true -license.workspace = true -description.workspace = true -readme.workspace = true -homepage.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[[bin]] -name = "ccc" -path = "src/ccc/mod.rs" - -[[bin]] -name = "hedu" -path = "src/hedu/mod.rs" - -[[bin]] -name = "libpt" -path = "src/main/mod.rs" - -[dependencies] -clap = { version = "4.4.4", features = ["derive"] } -clap-num = "1.0.2" -clap-verbosity-flag = "2.0.1" -libpt = { version = "0.2.0-alpha.2", path = "../..", features = [ - "default", - "ccc", - "math", - "hedu", - "net", - "log", -], registry = "cscherr" } diff --git a/members/libpt-bintols/Cargo.toml b/members/libpt-bintols/Cargo.toml index 3d0ca88..668a1a6 100644 --- a/members/libpt-bintols/Cargo.toml +++ b/members/libpt-bintols/Cargo.toml @@ -16,5 +16,7 @@ categories.workspace = true [dependencies] num-traits = "0.2.16" -libpt-core = { version = "0.2.0-alpha.2", path = "../libpt-core", registry="cscherr" } -libpt-log = { version = "0.2.0-alpha.2", path = "../libpt-log", registry="cscherr" } +libpt-core = { workspace = true } +libpt-log = { workspace = true } +anyhow = { workspace = true } +thiserror = { workspace = true } diff --git a/members/libpt-hedu/src/lib.rs b/members/libpt-bintols/src/hedu/mod.rs similarity index 100% rename from members/libpt-hedu/src/lib.rs rename to members/libpt-bintols/src/hedu/mod.rs diff --git a/members/libpt-ccc/Cargo.toml b/members/libpt-ccc/Cargo.toml deleted file mode 100644 index 4c47bdd..0000000 --- a/members/libpt-ccc/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "libpt-ccc" -publish.workspace = true -version.workspace = true -edition.workspace = true -authors.workspace = true -license.workspace = true -description.workspace = true -readme.workspace = true -homepage.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -num = "0.4.1" -num-traits = "0.2.16" -libpt-core = { version = "0.2.0-alpha.2", path = "../libpt-core", registry="cscherr" } -libpt-log = { version = "0.2.0-alpha.2", path = "../libpt-log", registry="cscherr" } -libpt-math = { version = "0.2.0-alpha.2", path = "../libpt-math", registry="cscherr" } diff --git a/members/libpt-core/Cargo.toml b/members/libpt-core/Cargo.toml index a2b89c9..cacd5b9 100644 --- a/members/libpt-core/Cargo.toml +++ b/members/libpt-core/Cargo.toml @@ -15,4 +15,4 @@ categories.workspace = true [dependencies] anyhow = "1.0.79" cucumber = "0.20.2" -libpt-log = { version = "0.2.0-alpha.2", path = "../libpt-log", registry="cscherr" } +libpt-log = { workspace = true } diff --git a/members/libpt-hedu/Cargo.toml b/members/libpt-hedu/Cargo.toml deleted file mode 100644 index 1247caf..0000000 --- a/members/libpt-hedu/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "libpt-hedu" -publish.workspace = true -version.workspace = true -edition.workspace = true -authors.workspace = true -license.workspace = true -description.workspace = true -readme.workspace = true -homepage.workspace = true -repository.workspace = true -keywords.workspace = true -categories.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -anyhow = { workspace = true } -thiserror = { workspace = true } -libpt-log = { version = "0.2.0-alpha.2", path = "../libpt-log", registry="cscherr" } -libpt-bintols = { version = "0.2.0-alpha.2", path = "../libpt-bintols", registry="cscherr" } diff --git a/members/libpt-math/Cargo.toml b/members/libpt-math/Cargo.toml index 343800c..34b56d1 100644 --- a/members/libpt-math/Cargo.toml +++ b/members/libpt-math/Cargo.toml @@ -15,3 +15,7 @@ categories.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +num = "0.4.1" +num-traits = "0.2.16" +libpt-core = { workspace = true } +libpt-log = { workspace = true } diff --git a/members/libpt-ccc/src/lib.rs b/members/libpt-math/src/ccc/mod.rs similarity index 100% rename from members/libpt-ccc/src/lib.rs rename to members/libpt-math/src/ccc/mod.rs diff --git a/members/libpt-net/Cargo.toml b/members/libpt-net/Cargo.toml index 43d80f1..4a4e4bf 100644 --- a/members/libpt-net/Cargo.toml +++ b/members/libpt-net/Cargo.toml @@ -16,9 +16,9 @@ categories.workspace = true [dependencies] humantime = "2.1.0" -libpt-core = { version = "0.2.0-alpha.2", path = "../libpt-core", registry="cscherr" } -libpt-log = { version = "0.2.0-alpha.2", path = "../libpt-log", registry="cscherr" } -libpt-math = { version = "0.2.0-alpha.2", path = "../libpt-math", registry="cscherr" } +libpt-core = { workspace = true } +libpt-log = { workspace = true } +libpt-math = { workspace = true } reqwest = { version = "0.11.20", features = ["blocking"] } serde = { version = "1.0.188", features = ["serde_derive"] } serde_json = "1.0.107" diff --git a/members/libpt-bin/src/ccc/mod.rs b/src/ccc/mod.rs similarity index 100% rename from members/libpt-bin/src/ccc/mod.rs rename to src/ccc/mod.rs diff --git a/members/libpt-bin/src/hedu/mod.rs b/src/hedu/mod.rs similarity index 100% rename from members/libpt-bin/src/hedu/mod.rs rename to src/hedu/mod.rs diff --git a/members/libpt-bin/src/main/args.rs b/src/main/args.rs similarity index 100% rename from members/libpt-bin/src/main/args.rs rename to src/main/args.rs diff --git a/members/libpt-bin/src/main/mod.rs b/src/main/mod.rs similarity index 100% rename from members/libpt-bin/src/main/mod.rs rename to src/main/mod.rs -- 2.40.1 From 4d390c3227bcb984966287f9a1658808550a4a25 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Wed, 17 Jan 2024 14:00:43 +0100 Subject: [PATCH 2/5] CI fix --- .gitea/workflows/cargo.yaml | 10 +-- Cargo.toml | 9 +++ src/main/args.rs | 124 ------------------------------------ src/main/mod.rs | 102 ----------------------------- 4 files changed, 14 insertions(+), 231 deletions(-) delete mode 100644 src/main/args.rs delete mode 100644 src/main/mod.rs diff --git a/.gitea/workflows/cargo.yaml b/.gitea/workflows/cargo.yaml index 7212c2b..8b35209 100644 --- a/.gitea/workflows/cargo.yaml +++ b/.gitea/workflows/cargo.yaml @@ -17,16 +17,16 @@ jobs: 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 -e '[registry] - cscherr= "cscherr" + echo -e '[registry]\n\ + cscherr= "cscherr"\n\ - [registries.cscherr] - index = "sparse+https://git.cscherr.de/api/packages/PlexSheep/cargo/" - ' > ~/.cargo/config.toml + [registries.cscherr]\n\ + index = "sparse+https://git.cscherr.de/api/packages/PlexSheep/cargo/"' > ~/.cargo/config.toml cat ~/.cargo/config.toml - name: cargo check run: cargo check --all-features --all-targets diff --git a/Cargo.toml b/Cargo.toml index 8fe001d..b44ed50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,6 +69,15 @@ crate-type = [ "rlib", ] +[[bin]] +name = "ccc" +path = "src/ccc/mod.rs" + +[[bin]] +name = "hedu" +path = "src/hedu/mod.rs" + + [dependencies] libpt-core = { workspace = true } libpt-bintols = { workspace = true } diff --git a/src/main/args.rs b/src/main/args.rs deleted file mode 100644 index 43d2266..0000000 --- a/src/main/args.rs +++ /dev/null @@ -1,124 +0,0 @@ -//! # args module -//! -//! The args module of libpt is used to parse commandline arguments. For this, it makes use of -//! [`clap`]. - -//// ATTRIBUTES //////////////////////////////////////////////////////////////////////////////////// -// we want docs -#![warn(missing_docs)] -#![warn(rustdoc::missing_crate_level_docs)] -//////////////////////////////////////////////////////////////////////////////////////////////////// -// we want Debug everywhere. -#![warn(missing_debug_implementations)] -//////////////////////////////////////////////////////////////////////////////////////////////////// -// enable clippy's extra lints, the pedantic version -#![warn(clippy::pedantic)] - -//// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// -use clap::{Parser, Subcommand}; - -use clap_num::number_range; - -use clap_verbosity_flag::{InfoLevel, Verbosity}; - -//// CONSTANTS ///////////////////////////////////////////////////////////////////////////////////// -/// short about section displayed in help -const ABOUT_ROOT: &'static str = r##" -Personal multi tool - - A collection of tools made for personal use -"##; -/// longer about section displayed in help, is combined with [the short help](ABOUT_ROOT) -static LONG_ABOUT_ROOT: &'static str = r##" - - libpt is a personal general purpose library, offering this executable, a python module and a - dynamic library. -"##; - -//// STATICS /////////////////////////////////////////////////////////////////////////////////////// -/// ## Main struct for parsing CLI arguments -/// -/// This struct describes the complete commandline options/arguments that [pt](crate) can take. It -/// makes use of composition to build a complex system of commands, subcommands, flags and options. -#[derive(Debug, Clone, Parser)] -#[command( - author, - version, - about = ABOUT_ROOT, - long_about = format!("{}{}", ABOUT_ROOT ,LONG_ABOUT_ROOT), - help_template = -r#"libpt: {version}{about-section}Author: -{author-with-newline} -{usage-heading} {usage}{all-args}{tab}"# - )] -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, - - /// show logger meta - #[arg(short, long, global = true)] - pub log_meta: bool, - - /// choose a subcommand - #[command(subcommand)] - pub command: Commands, -} - -//// ENUMS ///////////////////////////////////////////////////////////////////////////////////////// -/// ## defines the top level commands -#[derive(Debug, Clone, Subcommand)] -#[non_exhaustive] -pub enum Commands { - /// networking commands - Net { - /// Networking subcommands - #[command(subcommand)] - command: NetCommands, - }, -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// ## defines the networking commands -#[derive(Debug, Clone, Subcommand)] -#[non_exhaustive] -pub enum NetCommands { - /// monitor your network - Monitor { - /// repeat every N seconds, 0 means no repeat - #[clap(short, long, default_value_t = 0, name = "N")] - repeat: u64, - - /// At what percentage should the try be considered successful - #[clap(short, long, default_value_t = 100, value_parser=max100)] - success_ratio: u8, - - /// extra URLs to check with - extra_urls: Vec, - - /// Don't check for default URLs - #[clap(short, long)] - no_default: bool, - - /// set a timeout (in ms) - #[clap(short, long, default_value_t = 100)] - timeout: u64, - }, - /// discover hosts in your network - Discover {}, -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// - -//// STRUCTS /////////////////////////////////////////////////////////////////////////////////////// - -//// IMPLEMENTATION //////////////////////////////////////////////////////////////////////////////// - -//// PUBLIC FUNCTIONS ////////////////////////////////////////////////////////////////////////////// - -//// PRIVATE FUNCTIONS ///////////////////////////////////////////////////////////////////////////// -/// custom value parser, only allow 0 to 100 -fn max100(s: &str) -> Result { - number_range(s, 0, 100) -} diff --git a/src/main/mod.rs b/src/main/mod.rs deleted file mode 100644 index e7ba1bc..0000000 --- a/src/main/mod.rs +++ /dev/null @@ -1,102 +0,0 @@ -//! # Main executable of libpt -//! -//! This module contains all code specific to the executable version of [`pt`]: [`pt`](crate). -//! -//! - -//// ATTRIBUTES //////////////////////////////////////////////////////////////////////////////////// -// we want docs -#![warn(missing_docs)] -#![warn(rustdoc::missing_crate_level_docs)] -// we want Debug everywhere. -#![warn(missing_debug_implementations)] -// enable clippy's extra lints, the pedantic version -#![warn(clippy::pedantic)] - -//// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// -use libpt::{log::*, net::monitoring::uptime}; - -use clap::Parser; - -pub mod args; -use args::*; - -//// CONSTANTS ///////////////////////////////////////////////////////////////////////////////////// -#[allow(dead_code)] -//// STATICS /////////////////////////////////////////////////////////////////////////////////////// - -//// MACROS //////////////////////////////////////////////////////////////////////////////////////// - -//// ENUMS ///////////////////////////////////////////////////////////////////////////////////////// - -//// STRUCTS /////////////////////////////////////////////////////////////////////////////////////// - -//// IMPLEMENTATION //////////////////////////////////////////////////////////////////////////////// - -//// PUBLIC FUNCTIONS ////////////////////////////////////////////////////////////////////////////// -/// ## Main function of the [`pt`](crate) binary -pub fn main() { - 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, - _ => { - eprintln!("'{}' is not a valid loglevel", cli.verbose.to_string()); - std::process::exit(1); - } - }; - if cli.log_meta { - Logger::init(None, Some(ll)).expect("could not initialize Logger"); - } else { - // less verbose version - Logger::init_mini(Some(ll)).expect("could not initialize Logger"); - } - - trace!("started the main function"); - trace!("{:?}", &cli); - - match cli.clone().command { - Commands::Net { command } => net(&cli, command), - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -/// ## Process [`Net`](args::NetCommands) subcommands -pub fn net(cli: &Cli, command: NetCommands) { - match command { - NetCommands::Monitor { - repeat, - success_ratio, - extra_urls, - no_default, - timeout, - } => { - let urls: Vec; - if no_default { - urls = extra_urls; - } else { - let mut combined: Vec = Vec::new(); - for i in uptime::DEFAULT_CHECK_URLS { - combined.push(i.to_string()); - } - combined.extend(extra_urls); - urls = combined; - } - let _verbose = cli.verbose.log_level().is_some(); - if repeat > 0 { - uptime::continuous_uptime_monitor(success_ratio, urls, repeat * 1000, timeout); - } else { - let status = uptime::UptimeStatus::new(success_ratio, urls, timeout); - info!("status:\n{}", status); - } - } - NetCommands::Discover {} => { - todo!() - } - } -} - -//// PRIVATE FUNCTIONS ///////////////////////////////////////////////////////////////////////////// -- 2.40.1 From b1796933997a1316cbb53caa1139e2b6cec84b32 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Wed, 17 Jan 2024 14:05:07 +0100 Subject: [PATCH 3/5] cargo workspace management --- Cargo.toml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b44ed50..cea457b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,12 +29,10 @@ categories = [ anyhow = "1.0.79" thiserror = "1.0.56" libpt-core = { version = "0.2.0-alpha.2", path = "members/libpt-core", registry = "cscherr" } -libpt-bintols = { version = "0.2.0-alpha.2", path = "members/libpt-bintols", registry = "cscherr", optional = true } -libpt-hedu = { version = "0.2.0-alpha.2", path = "members/libpt-hedu", registry = "cscherr", optional = true } -libpt-log = { version = "0.2.0-alpha.2", path = "members/libpt-log", registry = "cscherr", optional = true } -libpt-math = { version = "0.2.0-alpha.2", path = "members/libpt-math", registry = "cscherr", optional = true } -libpt-ccc = { version = "0.2.0-alpha.2", path = "members/libpt-ccc", registry = "cscherr", optional = true } -libpt-net = { version = "0.2.0-alpha.2", path = "members/libpt-net", registry = "cscherr", optional = true } +libpt-bintols = { version = "0.2.0-alpha.2", path = "members/libpt-bintols", registry = "cscherr" } +libpt-log = { version = "0.2.0-alpha.2", path = "members/libpt-log", registry = "cscherr" } +libpt-math = { version = "0.2.0-alpha.2", path = "members/libpt-math", registry = "cscherr" } +libpt-net = { version = "0.2.0-alpha.2", path = "members/libpt-net", registry = "cscherr" } [package] name = "libpt" @@ -52,13 +50,11 @@ categories.workspace = true [features] default = ["log", "core"] -all = ["default", "math", "log", "bintols", "net", "ccc", "hedu", "core"] core = [] -math = ["dep:libpt-math"] -log = ["dep:libpt-log"] -bintols = ["dep:libpt-bintols"] -net = ["dep:libpt-net"] -ccc = ["math"] +math = [] +log = [] +bintols = [] +net = [] bin = ["bintols", "math", "dep:clap", "dep:clap-num", "dep:clap-verbosity-flag"] [lib] @@ -81,10 +77,8 @@ path = "src/hedu/mod.rs" [dependencies] libpt-core = { workspace = true } libpt-bintols = { workspace = true } -libpt-hedu = { workspace = true } libpt-log = { workspace = true } libpt-math = { workspace = true } -libpt-ccc = { workspace = true } libpt-net = { workspace = true } clap = { version = "4.4.4", features = ["derive"], optional = true } clap-num = { version = "1.0.2", optional = true } -- 2.40.1 From a4acae15800d792ab83cbef20a8b97c56ec47cfc Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Wed, 17 Jan 2024 14:15:24 +0100 Subject: [PATCH 4/5] restructuring complete --- .gitea/workflows/cargo-publish.yaml | 49 +++++++++++++-------------- .gitea/workflows/cargo.yaml | 12 +++---- Cargo.toml | 4 ++- members/libpt-bintols/src/hedu/mod.rs | 2 +- members/libpt-bintols/src/lib.rs | 1 + members/libpt-math/src/ccc/mod.rs | 2 -- members/libpt-math/src/lib.rs | 1 + src/hedu/mod.rs | 7 +++- src/lib.rs | 2 -- 9 files changed, 42 insertions(+), 38 deletions(-) diff --git a/.gitea/workflows/cargo-publish.yaml b/.gitea/workflows/cargo-publish.yaml index bf28f1f..ee85fd2 100644 --- a/.gitea/workflows/cargo-publish.yaml +++ b/.gitea/workflows/cargo-publish.yaml @@ -4,28 +4,27 @@ on: 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: config custom registry -# run: | -# mkdir -p ~/.cargo/ -# echo -e '[registry] -# cscherr= "cscherr" -# -# [registries.cscherr] -# index = "sparse+https://git.cscherr.de/api/packages/PlexSheep/cargo/" -# ' > ~/.cargo/config.toml -# cat ~/.cargo/config.toml -# - name: publish crates on git.cscherr.de -# run: | -# cargo workspaces publish --registry cscherr +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: 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: publish crates on git.cscherr.de + run: | + cargo workspaces publish --registry cscherr diff --git a/.gitea/workflows/cargo.yaml b/.gitea/workflows/cargo.yaml index 8b35209..1e95e1f 100644 --- a/.gitea/workflows/cargo.yaml +++ b/.gitea/workflows/cargo.yaml @@ -1,4 +1,4 @@ -name: Cargo Check, Format, Fix and Test +name: cargo devel CI on: push: branches: @@ -22,11 +22,11 @@ jobs: - name: config custom registry run: | mkdir -p ~/.cargo/ - echo -e '[registry]\n\ - cscherr= "cscherr"\n\ - - [registries.cscherr]\n\ - index = "sparse+https://git.cscherr.de/api/packages/PlexSheep/cargo/"' > ~/.cargo/config.toml + 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 diff --git a/Cargo.toml b/Cargo.toml index cea457b..f3347b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,7 @@ math = [] log = [] bintols = [] net = [] -bin = ["bintols", "math", "dep:clap", "dep:clap-num", "dep:clap-verbosity-flag"] +bin = ["dep:clap", "dep:clap-num", "dep:clap-verbosity-flag"] [lib] name = "libpt" @@ -68,10 +68,12 @@ crate-type = [ [[bin]] name = "ccc" path = "src/ccc/mod.rs" +required-features = ["bin", "math"] [[bin]] name = "hedu" path = "src/hedu/mod.rs" +required-features = ["bin", "bintols"] [dependencies] diff --git a/members/libpt-bintols/src/hedu/mod.rs b/members/libpt-bintols/src/hedu/mod.rs index aab45f2..686dba8 100644 --- a/members/libpt-bintols/src/hedu/mod.rs +++ b/members/libpt-bintols/src/hedu/mod.rs @@ -6,7 +6,7 @@ //! This crate is currently empty. use anyhow::{bail, Result}; -use libpt_bintols::display::{bytes_to_bin, humanbytes}; +use crate::display::{bytes_to_bin, humanbytes}; use libpt_log::{debug, error, info, trace, warn}; use std::io::{prelude::*, BufReader, Read, SeekFrom}; diff --git a/members/libpt-bintols/src/lib.rs b/members/libpt-bintols/src/lib.rs index ca13f78..36aa2bb 100644 --- a/members/libpt-bintols/src/lib.rs +++ b/members/libpt-bintols/src/lib.rs @@ -25,3 +25,4 @@ pub const YOBI: u128 = 2u128.pow(80); // use libpt_core; pub mod datalayout; pub mod display; +pub mod hedu; diff --git a/members/libpt-math/src/ccc/mod.rs b/members/libpt-math/src/ccc/mod.rs index 3b538a6..84efe1f 100644 --- a/members/libpt-math/src/ccc/mod.rs +++ b/members/libpt-math/src/ccc/mod.rs @@ -19,8 +19,6 @@ #![warn(clippy::pedantic)] //// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// -use libpt_log; -use libpt_math; //// TYPES ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/members/libpt-math/src/lib.rs b/members/libpt-math/src/lib.rs index c93077f..dbafa06 100644 --- a/members/libpt-math/src/lib.rs +++ b/members/libpt-math/src/lib.rs @@ -15,6 +15,7 @@ #![warn(clippy::pedantic)] //// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// +pub mod ccc; //// TYPES ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/hedu/mod.rs b/src/hedu/mod.rs index 91fe487..5010a7b 100644 --- a/src/hedu/mod.rs +++ b/src/hedu/mod.rs @@ -13,7 +13,7 @@ //// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// -use libpt::{hedu::*, log::*}; +use libpt::{log::*, bintols::hedu::*}; use clap::Parser; use clap_verbosity_flag::{InfoLevel, Verbosity}; @@ -88,6 +88,11 @@ pub struct Cli { /// If left empty or set as "-", the program will read from stdin. pub data_source: Option, } +impl Cli { + fn parse() -> Cli { + todo!() + } +} //// IMPLEMENTATION //////////////////////////////////////////////////////////////////////////////// diff --git a/src/lib.rs b/src/lib.rs index 1390701..8899a30 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,8 +12,6 @@ pub use libpt_bintols as bintols; pub use libpt_ccc as ccc; #[cfg(feature = "core")] pub use libpt_core as core; -#[cfg(feature = "hedu")] -pub use libpt_hedu as hedu; #[cfg(feature = "log")] pub use libpt_log as log; #[cfg(feature = "math")] -- 2.40.1 From 15fe2c1ce97f16ca3ac1599b23655210f21880ac Mon Sep 17 00:00:00 2001 From: cscherrNT Date: Wed, 17 Jan 2024 13:33:28 +0000 Subject: [PATCH 5/5] automatic cargo CI changes --- members/libpt-bintols/src/hedu/mod.rs | 2 +- src/hedu/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/members/libpt-bintols/src/hedu/mod.rs b/members/libpt-bintols/src/hedu/mod.rs index 686dba8..ce51c52 100644 --- a/members/libpt-bintols/src/hedu/mod.rs +++ b/members/libpt-bintols/src/hedu/mod.rs @@ -5,8 +5,8 @@ //! //! This crate is currently empty. -use anyhow::{bail, Result}; use crate::display::{bytes_to_bin, humanbytes}; +use anyhow::{bail, Result}; use libpt_log::{debug, error, info, trace, warn}; use std::io::{prelude::*, BufReader, Read, SeekFrom}; diff --git a/src/hedu/mod.rs b/src/hedu/mod.rs index 5010a7b..fca39ee 100644 --- a/src/hedu/mod.rs +++ b/src/hedu/mod.rs @@ -13,7 +13,7 @@ //// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// -use libpt::{log::*, bintols::hedu::*}; +use libpt::{bintols::hedu::*, log::*}; use clap::Parser; use clap_verbosity_flag::{InfoLevel, Verbosity}; -- 2.40.1