docu things i guess

This commit is contained in:
Christoph J. Scherr 2023-09-20 20:35:07 +02:00
parent cbd0717cc6
commit 9d1a242060
11 changed files with 58 additions and 32 deletions

View File

@ -15,4 +15,16 @@ categories.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # 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 = "pt"
path = "src/main/mod.rs"
[dependencies] [dependencies]
clap = { version = "4.4.4", features = ["derive"] }
clap-num = "1.0.2"
clap-verbosity-flag = "2.0.1"
libpt = { version = "0.1.7", path = "../..", features = ["ccc", "math", "hedu", "net"] }

View File

@ -15,11 +15,10 @@
#![warn(clippy::pedantic)] #![warn(clippy::pedantic)]
//// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// //// IMPORTS ///////////////////////////////////////////////////////////////////////////////////////
use pt::math::calculator::{*, self}; use libpt::ccc::*;
use pt::logger::*; use libpt::log::*;
use clap::{Parser, Subcommand}; use clap::Parser;
use clap_num::number_range;
use clap_verbosity_flag::{Verbosity, InfoLevel}; use clap_verbosity_flag::{Verbosity, InfoLevel};
use std::path::PathBuf; use std::path::PathBuf;
@ -42,6 +41,7 @@ static LONG_ABOUT_ROOT: &'static str = r##"
"##; "##;
//// STATICS /////////////////////////////////////////////////////////////////////////////////////// //// STATICS ///////////////////////////////////////////////////////////////////////////////////////
/// defines CLI interface
#[derive(Debug, Clone, Parser)] #[derive(Debug, Clone, Parser)]
#[command( #[command(
author, author,
@ -81,12 +81,12 @@ pub struct Cli {
//// PRIVATE FUNCTIONS ///////////////////////////////////////////////////////////////////////////// //// PRIVATE FUNCTIONS /////////////////////////////////////////////////////////////////////////////
fn main() { fn main() {
let cli = Cli::parse(); let cli = Cli::parse();
let ll: tracing::Level = match cli.verbose.log_level().unwrap().as_str() { let ll: Level = match cli.verbose.log_level().unwrap().as_str() {
"TRACE" => tracing::Level::TRACE, "TRACE" => Level::TRACE,
"DEBUG" => tracing::Level::DEBUG, "DEBUG" => Level::DEBUG,
"INFO" => tracing::Level::INFO, "INFO" => Level::INFO,
"WARN" => tracing::Level::WARN, "WARN" => Level::WARN,
"ERROR" => tracing::Level::ERROR, "ERROR" => Level::ERROR,
_ => { _ => {
eprintln!("'{}' is not a valid loglevel", cli.verbose.to_string()); eprintln!("'{}' is not a valid loglevel", cli.verbose.to_string());
std::process::exit(1); std::process::exit(1);

View File

@ -1,3 +0,0 @@
fn main() {
println!("Hello, world!");
}

View File

@ -15,11 +15,7 @@
//// IMPORTS /////////////////////////////////////////////////////////////////////////////////////// //// IMPORTS ///////////////////////////////////////////////////////////////////////////////////////
use pt::{logger, networking::monitoring::uptime, common::*}; use libpt::{log::*, net::monitoring::uptime};
// we want the log macros in any case
#[allow(unused_imports)]
use tracing::{debug, error, info, trace, warn};
use clap::Parser; use clap::Parser;
@ -45,19 +41,19 @@ use std::path::PathBuf;
/// ## Main function of the [`pt`](crate) binary /// ## Main function of the [`pt`](crate) binary
pub fn main() { pub fn main() {
let cli = Cli::parse(); let cli = Cli::parse();
let ll: tracing::Level = match cli.verbose.log_level().unwrap().as_str() { let ll: Level = match cli.verbose.log_level().unwrap().as_str() {
"TRACE" => tracing::Level::TRACE, "TRACE" => Level::TRACE,
"DEBUG" => tracing::Level::DEBUG, "DEBUG" => Level::DEBUG,
"INFO" => tracing::Level::INFO, "INFO" => Level::INFO,
"WARN" => tracing::Level::WARN, "WARN" => Level::WARN,
"ERROR" => tracing::Level::ERROR, "ERROR" => Level::ERROR,
_ => { _ => {
eprintln!("'{}' is not a valid loglevel", cli.verbose.to_string()); eprintln!("'{}' is not a valid loglevel", cli.verbose.to_string());
std::process::exit(EXIT_FAILURE_USAGE); std::process::exit(1);
} }
}; };
if cli.log_meta { if cli.log_meta {
logger::Logger::init_customized( Logger::init_customized(
false, false,
PathBuf::from("/dev/null"), PathBuf::from("/dev/null"),
true, true,
@ -72,7 +68,7 @@ pub fn main() {
.expect("could not initialize Logger"); .expect("could not initialize Logger");
} else { } else {
// less verbose version // less verbose version
logger::Logger::init_customized( Logger::init_customized(
false, false,
PathBuf::from("/dev/null"), PathBuf::from("/dev/null"),
true, true,

View File

@ -1,4 +1,7 @@
//* # Tools to work with binary values, memory, storage //* # Tools to work with binary values, memory, storage
//!
//! This crate is part of [`pt`](../libpt/index.html), but can also be used as a standalone
//! module.
// official binary prefixes, see [https://en.wikipedia.org/wiki/Binary_prefix] // official binary prefixes, see [https://en.wikipedia.org/wiki/Binary_prefix]
/// 2^10 /// 2^10

View File

@ -1,5 +1,8 @@
//! # Calculate expressions //! # Calculate expressions
//! //!
//! This crate is part of [`pt`](../libpt/index.html), but can also be used as a standalone
//! module.
//!
//! Calculate Calculations with your Calculator (`ccc`) //! Calculate Calculations with your Calculator (`ccc`)
//! //!
//! This modules aim is to take a term of any kind ([String]) and calculate it's value, be it //! This modules aim is to take a term of any kind ([String]) and calculate it's value, be it

View File

@ -1,7 +1,10 @@
//! # common functionalities //! # common functionalities
//! //!
//! This module implements common functionality useful for many use cases, such as macros, //! This crate is part of [`pt`](../libpt/index.html), but can also be used as a standalone
//! Formatting functions and more. //! module.
//!
//! This crate implements core functionality useful for many use cases, such as macros,
//! formatting functions and more.
//// ATTRIBUTES //////////////////////////////////////////////////////////////////////////////////// //// ATTRIBUTES ////////////////////////////////////////////////////////////////////////////////////
// we want docs // we want docs

View File

@ -1,3 +1,6 @@
fn main() { //! # Dump data
println!("Hello, world!"); //!
} //! This crate is part of [`pt`](../libpt/index.html), but can also be used as a standalone
//! module.
//!
//! This crate is currently empty.

View File

@ -1,5 +1,8 @@
//! # A specialized Logger for [`pt`](../libpt/index.html) //! # A specialized Logger for [`pt`](../libpt/index.html)
//! //!
//! This crate is part of [`pt`](../libpt/index.html), but can also be used as a standalone
//! module.
//!
//! For the library version, only the basic [`tracing`] is used, so that it is possible for //! For the library version, only the basic [`tracing`] is used, so that it is possible for
//! the end user to use the [`tracing`] frontend they desire. //! the end user to use the [`tracing`] frontend they desire.
//! //!

View File

@ -1,5 +1,8 @@
//! # General Mathmatics functionalities //! # General Mathmatics functionalities
//! //!
//! This crate is part of [`pt`](../libpt/index.html), but can also be used as a standalone
//! module.
//!
//! This module is currently empty, but will contain many math functionalities in a future version. //! This module is currently empty, but will contain many math functionalities in a future version.
//// ATTRIBUTES //////////////////////////////////////////////////////////////////////////////////// //// ATTRIBUTES ////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,8 @@
//! # various networking tools //! # various networking tools
//! //!
//! This crate is part of [`pt`](../libpt/index.html), but can also be used as a standalone
//! module.
//!
//! The networking module contains various tools related to connections. For example, it contains a //! The networking module contains various tools related to connections. For example, it contains a
//! tool that has the purpose to check if your connection is consistently available. //! tool that has the purpose to check if your connection is consistently available.