From 7fa40416c7a25326bb34101c680c427f228e1a4d Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Fri, 2 Feb 2024 09:39:43 +0100 Subject: [PATCH] remove the bins --- Cargo.toml | 12 +----- src/ccc/mod.rs | 104 ------------------------------------------------- 2 files changed, 2 insertions(+), 114 deletions(-) delete mode 100644 src/ccc/mod.rs diff --git a/Cargo.toml b/Cargo.toml index 0201931..2788037 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,13 +49,12 @@ keywords.workspace = true categories.workspace = true [features] -default = ["log", "core", "bin"] +default = ["log", "core"] core = [] math = [] log = [] bintols = [] net = [] -bin = ["dep:clap", "dep:clap-num", "dep:clap-verbosity-flag", "math", "bintols"] [lib] name = "libpt" @@ -65,17 +64,10 @@ crate-type = [ "rlib", ] -[[bin]] -name = "ccc" -path = "src/ccc/mod.rs" -required-features = ["bin", "math"] - [dependencies] +# FIXME: We don't want to compile all of the member crates regardless of features libpt-core = { workspace = true } libpt-bintols = { workspace = true } libpt-log = { workspace = true } libpt-math = { 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/src/ccc/mod.rs b/src/ccc/mod.rs deleted file mode 100644 index b12d116..0000000 --- a/src/ccc/mod.rs +++ /dev/null @@ -1,104 +0,0 @@ -//! # Executable for the math/compute submodule -//! -//! Calculate Calculations with your Computer! -//! -//! This command line tool allows you to input a mathematical expression. It will then process the -//! expression. - -//// 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::*; - -use clap::Parser; -use clap_verbosity_flag::{InfoLevel, Verbosity}; - -//// TYPES ///////////////////////////////////////////////////////////////////////////////////////// - -//// CONSTANTS ///////////////////////////////////////////////////////////////////////////////////// -/// short about section displayed in help -const ABOUT_ROOT: &'static str = r##" -Calculate Calculations with your Computer - - This commandline tool allows you to calculate complex mathematical expressions right in your - shell. -"##; -/// 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 /////////////////////////////////////////////////////////////////////////////////////// -/// defines CLI interface -#[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, - - /// your exporession(s) - #[clap(trailing_var_arg = true)] - pub expression: Vec, -} - -//// MACROS //////////////////////////////////////////////////////////////////////////////////////// - -//// ENUMS ///////////////////////////////////////////////////////////////////////////////////////// - -//// STRUCTS /////////////////////////////////////////////////////////////////////////////////////// - -//// IMPLEMENTATION //////////////////////////////////////////////////////////////////////////////// - -//// PUBLIC FUNCTIONS ////////////////////////////////////////////////////////////////////////////// - -//// PRIVATE FUNCTIONS ///////////////////////////////////////////////////////////////////////////// -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), false).expect("could not initialize Logger"); - } else { - // less verbose version - Logger::init_mini(Some(ll)).expect("could not initialize Logger"); - } - let mut expr: String = String::new(); - for part in cli.expression { - expr += ∂ - } -} -////////////////////////////////////////////////////////////////////////////////////////////////////