generated from PlexSheep/baserepo
Merge branch 'devel' of https://git.cscherr.de/PlexSheep/pt into devel
cargo devel CI / cargo CI (push) Successful in 2m30s
Details
cargo devel CI / cargo CI (push) Successful in 2m30s
Details
This commit is contained in:
commit
fb3d99d459
12
Cargo.toml
12
Cargo.toml
|
@ -49,13 +49,12 @@ keywords.workspace = true
|
||||||
categories.workspace = true
|
categories.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["log", "core", "bin"]
|
default = ["log", "core"]
|
||||||
core = []
|
core = []
|
||||||
math = []
|
math = []
|
||||||
log = []
|
log = []
|
||||||
bintols = []
|
bintols = []
|
||||||
net = []
|
net = []
|
||||||
bin = ["dep:clap", "dep:clap-num", "dep:clap-verbosity-flag", "math", "bintols"]
|
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "libpt"
|
name = "libpt"
|
||||||
|
@ -65,17 +64,10 @@ crate-type = [
|
||||||
"rlib",
|
"rlib",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "ccc"
|
|
||||||
path = "src/ccc/mod.rs"
|
|
||||||
required-features = ["bin", "math"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
# FIXME: We don't want to compile all of the member crates regardless of features
|
||||||
libpt-core = { workspace = true }
|
libpt-core = { workspace = true }
|
||||||
libpt-bintols = { workspace = true }
|
libpt-bintols = { workspace = true }
|
||||||
libpt-log = { workspace = true }
|
libpt-log = { workspace = true }
|
||||||
libpt-math = { workspace = true }
|
libpt-math = { workspace = true }
|
||||||
libpt-net = { 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 }
|
|
||||||
|
|
104
src/ccc/mod.rs
104
src/ccc/mod.rs
|
@ -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<InfoLevel>,
|
|
||||||
|
|
||||||
/// show logger meta
|
|
||||||
#[arg(short, long, global = true)]
|
|
||||||
pub log_meta: bool,
|
|
||||||
|
|
||||||
/// your exporession(s)
|
|
||||||
#[clap(trailing_var_arg = true)]
|
|
||||||
pub expression: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
//// 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 += ∂
|
|
||||||
}
|
|
||||||
}
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
Reference in New Issue