generated from PlexSheep/baserepo
Merge branch 'devel'
cargo devel CI / cargo CI (push) Successful in 1m54s
Details
cargo devel CI / cargo CI (push) Successful in 1m54s
Details
This commit is contained in:
commit
3bf60f86b1
17
Cargo.toml
17
Cargo.toml
|
@ -5,7 +5,7 @@ default-members = [".", "members/libpt-core"]
|
|||
|
||||
[workspace.package]
|
||||
publish = true
|
||||
version = "0.6.0"
|
||||
version = "0.7.1"
|
||||
edition = "2021"
|
||||
authors = ["Christoph J. Scherr <software@cscherr.de>"]
|
||||
license = "GPL-3.0-or-later"
|
||||
|
@ -19,10 +19,10 @@ categories = ["command-line-utilities", "development-tools"]
|
|||
[workspace.dependencies]
|
||||
anyhow = "1.0.79"
|
||||
thiserror = "1.0.56"
|
||||
libpt-core = { version = "0.4.0", path = "members/libpt-core" }
|
||||
libpt-core = { version = "0.5.0", path = "members/libpt-core" }
|
||||
libpt-bintols = { version = "0.5.1", path = "members/libpt-bintols" }
|
||||
libpt-log = { version = "0.5.1", path = "members/libpt-log" }
|
||||
libpt-cli = { version = "0.1.2", path = "members/libpt-cli" }
|
||||
libpt-log = { version = "0.6.0", path = "members/libpt-log" }
|
||||
libpt-cli = { version = "0.2.1", path = "members/libpt-cli" }
|
||||
|
||||
[package]
|
||||
name = "libpt"
|
||||
|
@ -41,8 +41,9 @@ categories.workspace = true
|
|||
[features]
|
||||
default = ["log", "core"]
|
||||
core = []
|
||||
full = ["default", "core", "log", "bintols"]
|
||||
full = ["default", "core", "log", "bintols", "libpt-cli/full"]
|
||||
log = ["dep:libpt-log"]
|
||||
log-crate = ["libpt-cli/log"]
|
||||
bintols = ["dep:libpt-bintols", "log"]
|
||||
cli = ["dep:libpt-cli", "core", "log"]
|
||||
|
||||
|
@ -58,4 +59,8 @@ crate-type = [
|
|||
libpt-core = { workspace = true }
|
||||
libpt-bintols = { workspace = true, optional = true }
|
||||
libpt-log = { workspace = true, optional = true }
|
||||
libpt-cli = { workspace = true, optional = true }
|
||||
libpt-cli = { workspace = true, optional = true, features = ["log"] }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
|
11
README.md
11
README.md
|
@ -40,12 +40,19 @@ If you want to use the python variant too, you need to compile with maturing.
|
|||
|
||||
## Installing from [pypi](https://pypi.org)
|
||||
|
||||
`libpt` has been packaged for [pypi.org](https://pypi.org/project/libpt/).
|
||||
The Python interface of `libpt` is currently not implemented, but it is planned
|
||||
to eventually re add it. Meanwhile, you can use a much older version if you
|
||||
really want.
|
||||
|
||||
You can install it with `pip install libpt`
|
||||
> :warning: **This will install a very old version**
|
||||
>
|
||||
> `libpt` has been packaged for [pypi.org](https://pypi.org/project/libpt/).
|
||||
>
|
||||
> You can install it with `pip install libpt`
|
||||
|
||||
## Installing from [crates.io](https://crates.io)
|
||||
|
||||
|
||||
`libpt` has been packaged for [crates.io](https://crates.io/crates/libpt).
|
||||
|
||||
You can add the library to your project with `cargo add libpt`.
|
||||
|
|
|
@ -20,3 +20,7 @@ libpt-core = { workspace = true }
|
|||
libpt-log = { workspace = true }
|
||||
anyhow = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "libpt-cli"
|
||||
publish.workspace = true
|
||||
version = "0.1.2"
|
||||
version = "0.2.1"
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
|
@ -12,11 +12,9 @@ repository.workspace = true
|
|||
keywords.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
|
||||
|
||||
[features]
|
||||
default = []
|
||||
full = ["log"]
|
||||
log = ["dep:log"]
|
||||
|
||||
[dependencies]
|
||||
|
@ -31,6 +29,11 @@ human-panic = "2.0.0"
|
|||
indicatif = "0.17.8"
|
||||
libpt-log = { workspace = true, optional = false }
|
||||
log = { version = "0.4.21", optional = true }
|
||||
serde = { version = "1.0.209", features = ["derive"] }
|
||||
shlex = "1.3.0"
|
||||
strum = { version = "0.26.3", features = ["derive"] }
|
||||
thiserror.workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use clap::Parser;
|
||||
use libpt_cli::args::VerbosityLevel;
|
||||
use libpt_cli::{clap, printing};
|
||||
use libpt_cli::printing;
|
||||
use libpt_log::{debug, Logger};
|
||||
|
||||
/// This is the help
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use console::style;
|
||||
use libpt_cli::printing;
|
||||
use libpt_cli::repl::{DefaultRepl, Repl};
|
||||
use libpt_cli::{clap, printing, strum};
|
||||
use libpt_log::{debug, Logger};
|
||||
|
||||
use clap::Subcommand;
|
||||
|
@ -73,7 +73,7 @@ fn main() -> anyhow::Result<()> {
|
|||
if !fancy {
|
||||
println!("{}", text.join(" "))
|
||||
} else {
|
||||
printing::blockprint(&text.join(" "), console::Color::Cyan)
|
||||
printing::blockprint(text.join(" "), console::Color::Cyan)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ use clap::Parser;
|
|||
use libpt_log::Level;
|
||||
#[cfg(feature = "log")]
|
||||
use log;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Custom help template for displaying command-line usage information
|
||||
///
|
||||
|
@ -77,9 +78,9 @@ Author: {author-with-newline}
|
|||
/// Get the loglevel like this:
|
||||
///
|
||||
/// ```no_run
|
||||
/// # use libpt_cli::args::VerbosityLevel;
|
||||
/// use libpt_cli::args::VerbosityLevel;
|
||||
/// use libpt_log::Level;
|
||||
/// # use clap::Parser;
|
||||
/// use clap::Parser;
|
||||
///
|
||||
/// # #[derive(Parser, Debug)]
|
||||
/// # pub struct Opts {
|
||||
|
@ -95,7 +96,7 @@ Author: {author-with-newline}
|
|||
/// let level: Level = opts.verbose.level();
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Parser, Clone, PartialEq, Eq, Hash)]
|
||||
#[derive(Parser, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
|
||||
pub struct VerbosityLevel {
|
||||
/// make the output more verbose
|
||||
#[arg(
|
||||
|
|
|
@ -4,13 +4,3 @@
|
|||
pub mod args;
|
||||
pub mod printing;
|
||||
pub mod repl;
|
||||
|
||||
pub use clap;
|
||||
pub use comfy_table;
|
||||
pub use console;
|
||||
pub use dialoguer;
|
||||
pub use exitcode;
|
||||
pub use human_panic;
|
||||
pub use indicatif;
|
||||
pub use shlex;
|
||||
pub use strum;
|
||||
|
|
|
@ -42,7 +42,7 @@ use console::{style, Color};
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use libpt_cli::console::Color;
|
||||
/// use console::Color;
|
||||
/// use libpt_cli::printing::blockprint;
|
||||
/// # fn main() {
|
||||
/// blockprint("Hello world!", Color::Blue);
|
||||
|
@ -64,7 +64,7 @@ pub fn blockprint(content: impl ToString, color: Color) {
|
|||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use libpt_cli::console::Color;
|
||||
/// use console::Color;
|
||||
/// use libpt_cli::printing::blockfmt;
|
||||
/// # fn main() {
|
||||
/// let formatted_content = blockfmt("Hello world!", Color::Blue);
|
||||
|
@ -93,8 +93,8 @@ pub fn blockfmt(content: impl ToString, color: Color) -> String {
|
|||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// use libpt_cli::comfy_table::{presets, CellAlignment, ContentArrangement};
|
||||
/// use libpt_cli::console::Color;
|
||||
/// use comfy_table::{presets, CellAlignment, ContentArrangement};
|
||||
/// use console::Color;
|
||||
/// use libpt_cli::printing::blockfmt_advanced;
|
||||
/// # fn main() {
|
||||
/// println!(
|
||||
|
|
|
@ -27,8 +27,8 @@ use libpt_log::trace;
|
|||
///
|
||||
/// ```no_run
|
||||
/// use libpt_cli::repl::{DefaultRepl, Repl};
|
||||
/// use libpt_cli::clap::Subcommand;
|
||||
/// use libpt_cli::strum::EnumIter;
|
||||
/// use clap::Subcommand;
|
||||
/// use strum::EnumIter;
|
||||
///
|
||||
/// #[derive(Subcommand, Debug, EnumIter, Clone)]
|
||||
/// enum ReplCommand {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "libpt-core"
|
||||
publish.workspace = true
|
||||
version = "0.4.0"
|
||||
version = "0.5.0"
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
|
@ -14,6 +14,9 @@ categories.workspace = true
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0.79"
|
||||
libpt-log = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
|
|
@ -8,3 +8,16 @@
|
|||
|
||||
/// macros to make things faster in your code
|
||||
pub mod macros;
|
||||
|
||||
/// ## Get the name of the crate that uses your library
|
||||
///
|
||||
/// Let's say you're writing the library `foo` and need the name of the crate that uses `foo`. With
|
||||
/// this function, you can get the name of the crate that uses `foo`.
|
||||
///
|
||||
/// Will return [None] if [`std::env::current_exe()`] errors or if conversion to [String] from [std::ffi::OsStr] fails.
|
||||
pub fn get_crate_name() -> Option<String> {
|
||||
if let Ok(exe) = std::env::current_exe() {
|
||||
return Some(exe.file_stem()?.to_str()?.to_string());
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "libpt-log"
|
||||
publish.workspace = true
|
||||
version = "0.5.1"
|
||||
version = "0.6.0"
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
|
@ -18,6 +18,11 @@ tracing-appender = "0.2.2"
|
|||
tracing-subscriber = "0.3.17"
|
||||
anyhow = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
libpt-core = { workspace = true, optional = false }
|
||||
|
||||
[dev-dependencies]
|
||||
gag = "1.0.0"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
|
|
@ -480,5 +480,11 @@ impl Default for Logger {
|
|||
}
|
||||
|
||||
fn new_file_appender(log_dir: PathBuf) -> tracing_appender::rolling::RollingFileAppender {
|
||||
tracing_appender::rolling::daily(log_dir, format!("{}.log", env!("CARGO_CRATE_NAME")))
|
||||
tracing_appender::rolling::daily(
|
||||
log_dir,
|
||||
format!(
|
||||
"{}.log",
|
||||
libpt_core::get_crate_name().unwrap_or_else(|| "logfile".to_string())
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
Reference in New Issue